0

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

1 Answer 1

1

Got the root cause of the issue.

The fnGetData was being called as oTable.fnGetData() , and oTable was equal to the initial datatable that I had painted.

hence whenever I was calling the fnGetData() , it would return the original value of the Datatables

I am now looping over each tr and getting the current value.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.