views:

23

answers:

0

I am creating dynamic radio buttons on the server side and adding it to a particular column of a jquery datatable.

This is what i am doing on the server side.

string radio = "<label id='lbl" + index + "'><input type='radio' value='2'  id='" + radioButtonName + "' name ='" + radioButtonName + "' />" + "Rejected</label> <br>" +
"<label id='lbl" + index + "'><input type='radio' value='4' id='" + radioButtonName + "' name ='" + radioButtonName + "' checked />" + "Pending </label><br>" +
"<label id='lbl" + index + "'><input type='radio' value='5' id='" + radioButtonName + "' name ='" + radioButtonName + "' />" + "Approved </label><br>";

and, then on the client side I am equating the value of a column and then retrieving the values of the radio button. The value is captured only if the selection is changed.

   function GetRunStatuses() {
        var updatedRuns = new Array();
        var radioButtonName = '';
        var newState = '';

        // get the runs from the data table
        var runRows = runStatusTable.fnGetNodes();

        //iterate over the rows and create a list of
        //runs whose status have been updated
        for (var i = 0; i < runRows.length; i++) {
            if (runRows[i] != null) {
                var aData = runStatusTable.fnGetData(i);
                if (aData[2] == 4) {
                    radioButtonName = 'input[name=rdbStatus' + i + ']:checked';
                    newState = $(radioButtonName).val();

                    //check if the new state is other than 4.
                    if (newState != '4' && newState != undefined) {
                        //yes, we need to update the state in the server
                        var newRun = new Object();
                        newRun.Key = aData[0];
                        newRun.Status = newState;
                        isModified = true;
                        //add to the array
                        updatedRuns[updatedRuns.length] = newRun;
                    }

                }
            }
        }

        return updatedRuns;
    }

THE PROBLEM IS, MY RECORDS COME IN A DATATABLE ON MULTIPLE PAGES. THE PAGE THAT I AM CURRENTLY ON, GIVES THE CORRECT VALUE OF THE RADIO BUTTON, BUT ALL THE OTHER PAGES GIVES ME A VALUE 'undefined'.

PLEASE DO TELL ME WHY IS IT SO, AND HOW IT CAN BE SOLVED.