Custom footer text entries based on checked records.

Custom footer text entries based on checked records.

ram3772340ram3772340 Posts: 5Questions: 0Answers: 0
edited July 2011 in General
Hello,
I have a grid with a check box column (the header also has a 'Select All' option that checks and unchecks all the boxes in the grid). I need to modify the 'sInfo' text to say something like this "Showing 1 to 10 of 39 entries - 39 selected" and it has to change every time when there is a change in the number of selected checkboxes changes. Like an event to be called when a check box value changes or any way to bind the text with the check box entries. My code is as follows,
[code]var oTable1 = $('#gridDocuments').dataTable({
"bJQueryUI": true,
"aoColumns": [{ "sTitle": "Select all ", "sWidth": "10em", "bSortable": false }, null, { "sWidth": "14em" }, { "sWidth": "14em" }, { "sWidth": "10em", "bSortable": false}],
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, 'All']],
"iDisplayLength": 25,
"oLanguage": { "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries - _SELECTED_ selected" }
});
$('#check_all1').click(function () {
$('input', oTable1.fnGetNodes()).attr('checked', this.checked);
});
[/code]

Question 2: Is there any way to call a event in this case '$('#check_all1').click' when the grid is filtered. As when users use the filter in the backround the hidden records are by default selected. I think this can be sorted when unchecking all the checkboxes when the grid is filtered.

By the way this grid is really cool. Keep up the good work.
Thanks ahead,
Ram

Replies

  • ram3772340ram3772340 Posts: 5Questions: 0Answers: 0
    edited July 2011
    I have almost found a way to solve the first problem. By using fnInfoCallBack.
    [code]"fnInfoCallback": function (oSettings, iStart, iEnd, iMax, iTotal, sPre) {
    //var selectedCount = $('input', fnGetNodes()).serialize(); //I need a way to access the nodes from inside the fnInfoCallBack
    return "Showing " + iStart + " to "+ iEnd + " of " + iTotal + " entries - " + selectedCount + " selected";
    }[/code]
  • ram3772340ram3772340 Posts: 5Questions: 0Answers: 0
    I have solved the first question to hide a header content when there is a content in the filter.
    [code]
    $('#gridDocuments_filter input').keyup(function () {
    if ($(this).val().length > 0) {
    $('#check_all1').attr('style', 'visibility:hidden;');
    document.getElementById('lblCheckAll1').innerHTML = "";
    }
    else {
    $('#check_all1').attr('style', 'visibility:visible;');
    document.getElementById('lblCheckAll1').innerHTML = "Select all ";
    }
    });
    [/code]
    Thanks,
    Ram
This discussion has been closed.