Hi All,
Im attempting to switch to server side processing bit have spent hours and hours trying to manage the state of my checkbox column between pages.
Any ideas where im going wrong? I have started with the example:
http://datatables.net/examples/server_side/select_rows.html
But that doesnt work as .live isnt supported anymore and it highlights the row not checks a checkbox.
Im using both fnDrawCallback and fnRowCallback.
The current code will save row id's into the array when you click them but when you switch between pages it looks like the fnRowCallback event doesnt get called at all when you switch back to page 1.
Eg. On page 1 click to go to page 2 (It will fire the rowcallback then and loop through elements on page 1)
You click to go back to page 1 and no rowcallback fires?
I havent even got to "select all" functionality yet, Feeling like this could be days/weeks of work.
Any help would be much appreciated.
Thanks,
Matt
Im attempting to switch to server side processing bit have spent hours and hours trying to manage the state of my checkbox column between pages.
Any ideas where im going wrong? I have started with the example:
http://datatables.net/examples/server_side/select_rows.html
But that doesnt work as .live isnt supported anymore and it highlights the row not checks a checkbox.
Im using both fnDrawCallback and fnRowCallback.
The current code will save row id's into the array when you click them but when you switch between pages it looks like the fnRowCallback event doesnt get called at all when you switch back to page 1.
Eg. On page 1 click to go to page 2 (It will fire the rowcallback then and loop through elements on page 1)
You click to go back to page 1 and no rowcallback fires?
var oTable; var gaiSelected = []; $(document).ready(function() { oTable = $('#overview_results').dataTable( { "bProcessing": true, "bServerSide": true, "sAjaxSource": 'searchoverview_ajaxdatav3.php?runid='+qs('runid'), "sPaginationType": "full_numbers", "iDisplayLength": 50, "bSortClasses": false, "fnDrawCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) { $("input[name=rowchk]").click(function(event){ //Add to array var iId = event.target.id; if ( jQuery.inArray(iId, gaiSelected) == -1 ) { gaiSelected[gaiSelected.length++] = iId; } else { gaiSelected = jQuery.grep(gaiSelected, function(value) { return value != iId; } ); } console.log("Array: " + gaiSelected); }); }, "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { var chkid = $("input[name=rowchk]"); chkid.each( function(index,element) { if (jQuery.inArray($(element).attr("id"), gaiSelected) != -1 ) { console.log("Elements state of ID: " + $(element).attr("id") + " before row callback: "+$(element).prop("checked")); $(element).prop('checked', true); console.log("Elements state of ID: " + $(element).attr("id") + " after row callback: "+$(element).prop("checked")); } return nRow; }); },
I havent even got to "select all" functionality yet, Feeling like this could be days/weeks of work.
Any help would be much appreciated.
Thanks,
Matt