Programmatically update pagination controls

Programmatically update pagination controls

nadernader Posts: 2Questions: 0Answers: 0
edited February 2011 in General
So I'm using datatables in an unusual way. I've set it up for server-side processing, but I've hijacked the success method, and simply return the body of the html table and replace the tbody contents. I do this because the table is fairly complex html and it would be a big effort to just return the data in json, and then create all the same html via javascript.
[code]
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* change the success callback method */
$.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": my_success_handler
} );
}
[/code]

This is working fine. The sorting and pagination requests are passing parameters to my server and things are working great. Except for one issue. Because I'm not hooking into the built in success handler and I'm not passing back the json with the # of total rows, the pagination controls show up with prev / next /etc, but are not smart enough to be disabled if there aren't more, or show the number of items, etc.

Is there anyway I can tell the table to just update the pagination controls, but somehow programmatically passing in the iTotalRecords and iTotalDisplayRecords?

Replies

  • nadernader Posts: 2Questions: 0Answers: 0
    Figured it out in case anyone is curious. I needed to save the original success callback, and then in my handler call that with the correct record numbers, but an empty data array, and then replace the body with my html.
This discussion has been closed.