bServerSide dilemma

bServerSide dilemma

rashed_karimrashed_karim Posts: 5Questions: 0Answers: 0
edited October 2011 in General
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?

Replies

  • OmnimikeOmnimike Posts: 22Questions: 0Answers: 0
    What you seem to be looking for is fnReloadAjax which can be found here http://www.datatables.net/plug-ins/api.
  • rashed_karimrashed_karim Posts: 5Questions: 0Answers: 0
    edited October 2011
    Well I did try using fnReloadAjax, but I get an error (firebug console) in line 17 of the plug-in:
    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.
  • rashed_karimrashed_karim Posts: 5Questions: 0Answers: 0
    edited October 2011
    fnReloadAjax now works after I downloaded the latest version (v 1.8.2) of DataTable. Allan on Oct 7, 2011 writes about the fnGetObjectDataFn function being added to DataTable here in a forum reply:
    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.
This discussion has been closed.