invoke the Info callback

invoke the Info callback

mdusoemdusoe Posts: 2Questions: 0Answers: 0
edited September 2012 in DataTables 1.9
I have a table with rows that contain a checkbox for selection. I have code to get the number of selected rows like this:
[code]
function countSelected(){
if(tbl){
return jQuery('input[name=selected_proposal]:checked', tbl.fnGetNodes()).length;
}
return 0;
}
[/code]

I then init the table like this, using that function to return a modified info string:
[code]
return jQuery('.dataGrid').dataTable({

"fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) {
var count = countSelected();
var str = "";
if(count > 0){
str = ", " + count + " of which are selected."
}

return sPre + str;
},
"bAutoWidth": false,
"bJQueryUI": true,
"bPaginate": true,
"bSort": true,
"bInfo": true,
"sScrollX": "100%",
"sScrollXInner": "150%",
"bFilter": true
})
[/code]

My question is, how do I get the Info to redraw on the check of a box? When the user checks a box, the info string is not updated until they change pages or change filters or something else that causes a Draw. Unfortunately, calling tbl.fnDraw() in the click handler doesn't work, because it always sends them back to page 1.

Thanks in advance for any help you can provide.
Mike.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Try calling fnDraw( false ), which will effectively do a standing draw.

    Allan
  • mdusoemdusoe Posts: 2Questions: 0Answers: 0
    edited September 2012
    This did not work. The table resets to page 1 on every fnDraw call. I worked around it by not messing with the info string, I made it so that it keeps a total checked count on a button outside the table, but I would still like to make this happen. Any other ideas?

    Edit - But thank you for the response :)
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Okay - try this plug-in then: http://datatables.net/plug-ins/api#fnStandingRedraw :-)

    Allan
This discussion has been closed.