Sort spring form:checkbox column
Sort spring form:checkbox column
ryansfryin
Posts: 2Questions: 0Answers: 0
Hello everyone,
I was successfully able to sort a regular vanilla HTML checkbox column using the following code:
[code]
$.fn.dataTableExt.afnSortData['dom-checkbox'] = function ( oSettings, iColumn )
{
var aData = [];
$( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
aData.push( this.checked==false ? "1" : "0" );
} );
return aData;
};
[/code]
However, I am using the Spring 3 form tags library, specifically a which generates a regular HTML checkbox in addition to a hidden input which determines if the checkbox is on or off. This is what one of the Select column cells would look like:
[code]
[/code]
Is there a way I can sort a column of spring form checkboxes? Does anyone have any suggestions on how to tackle this?
I was successfully able to sort a regular vanilla HTML checkbox column using the following code:
[code]
$.fn.dataTableExt.afnSortData['dom-checkbox'] = function ( oSettings, iColumn )
{
var aData = [];
$( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
aData.push( this.checked==false ? "1" : "0" );
} );
return aData;
};
[/code]
However, I am using the Spring 3 form tags library, specifically a which generates a regular HTML checkbox in addition to a hidden input which determines if the checkbox is on or off. This is what one of the Select column cells would look like:
[code]
[/code]
Is there a way I can sort a column of spring form checkboxes? Does anyone have any suggestions on how to tackle this?
This discussion has been closed.
Replies
[code]
$.fn.dataTableExt.afnSortData['dom-checkbox'] = function ( oSettings, iColumn )
{
var aData = [];
$( 'td:eq('+iColumn+') input:checkbox', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
aData.push( this.checked==false ? "1" : "0" );
} );
return aData;
};
[/code]
I added the :checkbox selector to input so that it only looks for checkboxes. Since Spring form:checkbox generates two inputs, one checkbox, and one hidden, the original code was finding both and breaking.