[solved]link datatables to external form and send server request
[solved]link datatables to external form and send server request
asterix45
Posts: 2Questions: 1Answers: 0
Hi,
I'm new of datatables and I'm trying to link it to an external form (not made with datatables) and then showing result.
I'm working like this because of more flexibility and also because I've a form validator acting on my form.
What I do is:
- start datatables specifying columns and other params. I set datatables to work locally (not in server side) with empty data.
- start the form validator and get all the requested params (after validating).
Now I would like to
- change datatables settings in order to switch to server-side mode.
- add ajax url and form data.
- perform a request to the server and let datatables manage the results.
This is my code:
//datatables starts
$('#results').DataTable({
"responsive": true,
"processing": true,
//"serverSide": true, //don't want server side now
//"ajax": //don't set any ajax param
"bFilter": false,
"columns": [
{"data": "name"},
{"data": "email"}
]
});
...
//on form validation I do this
var formData = $('#myForm').serialize();
var tSettings=$('#results').dataTable().fnSettings();
tSettings.sAjaxSource='request_processing.php';
tSettings.sAjaxData=formData;
tSettings.serverSide=true;
$('#results').dataTable().fnDraw(false);
logging tSetting seems to me that the new configuration is received but no request are made to the server, also if, for example, I change the row number value.
Thanks for the help
This discussion has been closed.
Answers
I've searched in the forum and by Google and I found that it's not possible to change the entire ajax param through api
And since it is not possible I need to destroy and restart datatables, so I save my old configuration in a variable and modify it when I need it again.
forum