I have painted a checkbox against each row in my datatable using the following function
"fnRender": function ( oObj ) {
return '<input id="chkBox" name="chkBox" value="'+ oObj.aData[0] +'" type="checkbox" />'; }
In the onchange event I am changing the value of the checkbox to “Y”, like this.
$('#myDataTable input:checkbox').live('change', function (event) {
if($(this).is(":checked")) {
$(this).val("Y");
}
});
I have to now check all those rows whose checkbox value is “Y” and submit the same. However on form submit when I try to retrive the values of the checkboxes against each tr , like this
$('#myDataTable tr').each(function() {
var aData = oTable.fnGetData(this);
The array returned by fnGetData does not contain the updated value of the checkbox.
However when I evaulate the value of this passed as a parameter to fnGetData in Firebug , it shows the updated value of the checkbox.
I am unable to understand this behaviour of fnGetData , why does it not show me the updated value of the checkbox
Can anybody please help
Got the root cause of the issue.
The fnGetData was being called as
oTable.fnGetData(), andoTablewas equal to the initial datatable that I had painted.hence whenever I was calling the
fnGetData(), it would return the original value of the DatatablesI am now looping over each
trand getting the current value.