Post new server side request in fnInitComplete
Post new server side request in fnInitComplete
John Archer
Posts: 56Questions: 1Answers: 0
Hi there!
Here is what I do: I use server side processing for getting data, filtering and sorting. I have a HTML form, where each input field can be filled with a certain value from my database (e.g. "Status" can be "opened", "edited", "closed", ...). My aim is to preselect the correct row in my DataTable if it detects that "edited" is in the input field. This works quite nicely in "fnInitComplete" (I have the ID of the entries "edited", ... in a hidden column to determine the correct row), but I have a problem, if the neede status is not on the first page (1 - 25), but on the second or third.
So my idea was that if I do not find the proper ID in my hidden column, the status is not in this first page. So I want to do a new request with all the given parameters (my ones and DataTable ones, e.g. DisplayLength). I did a lot of research, but couldn't find a solution. I thought using oTable.fnPageChange('next'); would do exactly what I want, but it never reaches/calls my script which I define as sAjaxSource (my server side processing script). The call does the pagination correctly (I am on page 2, entries 26 - 50), but the data, that is shown, are the entries 1 -25.
I also tried to manually build a new ajax-Request:
var myAoData = new Array();
myAoData.push( { "name": "myName", "value": "myValue" } );
var xhr = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": "DataTableServerProcessing.php",
"data": myAoData
});
At least now I reach my server side processing script, and myAoData is posted correctly but now I am missing als the DataTable settings.
I hope there is a better way to repopulate my request to the server (as I said, oTable.fnPageChange('next') looks quite promising, but does not work).
Thanks a lot in advance!
Greetings!
Here is what I do: I use server side processing for getting data, filtering and sorting. I have a HTML form, where each input field can be filled with a certain value from my database (e.g. "Status" can be "opened", "edited", "closed", ...). My aim is to preselect the correct row in my DataTable if it detects that "edited" is in the input field. This works quite nicely in "fnInitComplete" (I have the ID of the entries "edited", ... in a hidden column to determine the correct row), but I have a problem, if the neede status is not on the first page (1 - 25), but on the second or third.
So my idea was that if I do not find the proper ID in my hidden column, the status is not in this first page. So I want to do a new request with all the given parameters (my ones and DataTable ones, e.g. DisplayLength). I did a lot of research, but couldn't find a solution. I thought using oTable.fnPageChange('next'); would do exactly what I want, but it never reaches/calls my script which I define as sAjaxSource (my server side processing script). The call does the pagination correctly (I am on page 2, entries 26 - 50), but the data, that is shown, are the entries 1 -25.
I also tried to manually build a new ajax-Request:
var myAoData = new Array();
myAoData.push( { "name": "myName", "value": "myValue" } );
var xhr = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": "DataTableServerProcessing.php",
"data": myAoData
});
At least now I reach my server side processing script, and myAoData is posted correctly but now I am missing als the DataTable settings.
I hope there is a better way to repopulate my request to the server (as I said, oTable.fnPageChange('next') looks quite promising, but does not work).
Thanks a lot in advance!
Greetings!
This discussion has been closed.
Replies
Sorry for replying to myself, but does anyone has a clue to solve my problem?
Thanks a lot and happy new year!
Greetings