*BUG* found in "live DOM sorting example". Filtering checkboxes returns them to default value

*BUG* found in "live DOM sorting example". Filtering checkboxes returns them to default value

uberspeckuberspeck Posts: 5Questions: 0Answers: 0
edited August 2012 in General
From the Live Sorting example @ http://datatables.net/examples/plug-ins/dom_sort.html

If you change the default value of any of the checkboxes then use the "Search:" filter the checkboxes return to their default state (seems to only affect IE6). This happens when using the example code (below). Maybe there's an alternative to work around this?

[code]/* Create an array with the values of all the checkboxes in a column */
$.fn.dataTableExt.afnSortData['dom-checkbox'] = function ( oSettings, iColumn )
{
var aData = [];
$( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
aData.push( this.checked==true ? "1" : "0" );
} );
return aData;
}[/code]

Replies

  • allanallan Posts: 65,430Questions: 1Answers: 10,865 Site admin
    Unfortunately this is an IE6 bug. When the element is removed from the document the checkbox loses its checked state and is not restored when you put it back into the document.

    The best that could be done is to have a live event handler on the checkboxes and to store a list of the checkboxes and their state - then in fnDrawCallback go through all checkboxes and restore their state.

    Horrible solutions, but its the only one I've found when I've worked on this issue in the past.

    However, as you say, this should only effect IE6.

    Allan
  • uberspeckuberspeck Posts: 5Questions: 0Answers: 0
    I was afraid of that. Thanks for the response!
This discussion has been closed.