bServerSide dilemma
bServerSide dilemma
rashed_karim
Posts: 5Questions: 0Answers: 0
Dear all,
I have a datable defined in this way;
[code]
hJobTable = $('#HighJobs').dataTable( {
"sScrollY": 400,
"iDisplayLength": 50,
"bFilter": true,
"bJQueryUI": true,
"bProcessing": true,
"sPaginationType": "full_numbers",
"bServerSide": false, /* This must be set to false to enable client-side sorting and searching */
"aaSorting": [[ 4, "asc" ]], /* this enables data to be presented by sorting on a default column */
"sAjaxSource": "processJobRequests.php?processID=2",
"asStripClasses":[], /* To strip the deault zebra stripes in datatable rows - alternate row color */
"aoColumns": [
{"bVisible": false, "bSearchable": false},
{ "bSearchable": true },
{ "bSearchable": true },
{"bSearchable": false },
{"bVisible": false, "bSearchable": false}
],
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull)
{
// some callback
}
} );
[/code]
I wish to take advantage of the client-side sorting and searching, so I duly set 'bServerSide' to false. However, the table is still able to load from the AJAX source. Search and sorting columns works fine. No problems so far ...
Now problem arises, when I go on to refresh table using fnDraw( ). The table doesn't refresh from the AJAX source, I checked the PHP end, there is no GET request sent out. However, if I set 'bServerSide' to true, refresh works like a charm, but the client-side search and sorting breaks down!! :((
Please help, it seems there must be a way out of this? How can i make both client-side search and refresh from AJAX work?
I have a datable defined in this way;
[code]
hJobTable = $('#HighJobs').dataTable( {
"sScrollY": 400,
"iDisplayLength": 50,
"bFilter": true,
"bJQueryUI": true,
"bProcessing": true,
"sPaginationType": "full_numbers",
"bServerSide": false, /* This must be set to false to enable client-side sorting and searching */
"aaSorting": [[ 4, "asc" ]], /* this enables data to be presented by sorting on a default column */
"sAjaxSource": "processJobRequests.php?processID=2",
"asStripClasses":[], /* To strip the deault zebra stripes in datatable rows - alternate row color */
"aoColumns": [
{"bVisible": false, "bSearchable": false},
{ "bSearchable": true },
{ "bSearchable": true },
{"bSearchable": false },
{"bVisible": false, "bSearchable": false}
],
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull)
{
// some callback
}
} );
[/code]
I wish to take advantage of the client-side sorting and searching, so I duly set 'bServerSide' to false. However, the table is still able to load from the AJAX source. Search and sorting columns works fine. No problems so far ...
Now problem arises, when I go on to refresh table using fnDraw( ). The table doesn't refresh from the AJAX source, I checked the PHP end, there is no GET request sent out. However, if I set 'bServerSide' to true, refresh works like a charm, but the client-side search and sorting breaks down!! :((
Please help, it seems there must be a way out of this? How can i make both client-side search and refresh from AJAX work?
This discussion has been closed.
Replies
that.oApi._fnGetObjectDataFn is not a function
Not sure what I am doing wrong. Copied the code for fnReloadAjax from link above into a .js and included the file before table init and after loading jquery.datatables.js in this way:
[code]
[/code]
Also should bServerSide be set to 'true' for fnReloadAjax ? If so, I loose client-side search and sort capabilities.
http://www.datatables.net/forums/discussion/6903/fnreloadajax-causing-uncaught-typeerror-cannot-read-property-length-of-undefined/p1
So with fnReloadAjax I refresh the datatable and have bServerSide set to false. This allows me to take advantage of the built-in row search and sort capabilities (client-side only) of DataTable.