Checkbox sort problem

Checkbox sort problem

rfitzwaterrfitzwater Posts: 57Questions: 5Answers: 1
edited December 2011 in DataTables 1.8
I have a table a checkbox column. I would like to be able to sort based on checked value. I referenced the dom-sort example (http://datatables.net/examples/plug-ins/dom_sort.html), but I am not having any luck. I keeping getting a error of (DataTables warning (table id = 'example'): Requested unknown parameter '0' from the data source for row 1). Looking at the console log, I see this error: TypeError: 'null' is not an object (evaluating 'a.replace').

Can anyone tell what I am doing wrong? If I remove the code below, everything loads fine,but sorting on the checkbox column does not work.

[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]

Any help is appreciated.

Thanks,

-Rhon

Replies

  • rfitzwaterrfitzwater Posts: 57Questions: 5Answers: 1
    Anyone able to take a look and shed some light? Thanks!
  • rfitzwaterrfitzwater Posts: 57Questions: 5Answers: 1
    Anyone able to help?
  • mdraytonmdrayton Posts: 2Questions: 0Answers: 0
    Hi,

    I received a similar error message when using a hidden column. I had to move my hidden column from the middle to the end of the table before [code]$.fn.dataTableExt.afnSortData[/code] would work.

    i quickly glanced at your page, and didn't notice any hidden columns -- so I'm guessing that your problem is caused by something else. (Thought I post this anyway, just in case it helps out someone else)

    Good luck!
This discussion has been closed.