samedi 27 décembre 2014

Retrieving checkbox value in a dataTable

I have a datatable in which one of the columns is a bool. I display the value as a check box as such:



{
"mData": "IsAssociated", "mRender": function (data, type, full ) {
if (data == "true")
{
return '<input type="checkbox" checked="checked" />';
}
else
{
return '<input type="checkbox" />';
}
}
}


This works perfectly fine and the column appears as a check box in the datatable with the appropriate value (checked if true, unchecked if false). The problem i am having is retrieving the value of the column. I am using the "created row" callback in order to execute some jquery code as such:



"createdRow": function ( row, data, index ) {
alert(data[0]); //this works and return the integer value stored in the 0 column.
alert(data[1]); //this works and return the string value stored in the 1 column.
alert(data[2]); //this is the boolean column and this does not work. I get an "undefined"
//in the popup box that appears.
}


I have tried using the (bool) cast but that does not work either. How can I retrieve the value of the checkbox? Thanks.





Aucun commentaire:

Enregistrer un commentaire