I have a fairly complex grid with two columns formatted as a checkbox. Those columns are defined as follow:
{ name: 'Alert_A', index: 'Alert_A', width: 22, align: 'center', sortable: false,
formatter: CheckBoxFormatter, editable: true, edittype: 'checkbox', editoptions: {value: "True:False"},
formatoptions: {disabled: false}, classes: "Alert_A" },
{ name: 'Alert_B', index: 'Alert_B', width: 22, align: 'center', sortable: false,
formatter: CheckBoxFormatter, editable: true, edittype: 'checkbox', editoptions: { value: "True:False" },
formatoptions: {disabled: false}, classes: "Alert_B" }
The custom formatter CheckBoxFormatter
is needed because I need to setup the disabled attribute of each checkbox depending on some custom rules, so I borrowed the native 'checkbox' formatter and added my custom rules.
I also have an external html button element and when I click on it I need to execute some code depending on which combination of checkbox selection have been made. My code looks like this:
$('#btnAlert').button().click(function (event) {
event.preventDefault();
var dashboardID = '#<%=dashboard.ClientID %>';
doWork(dashboardID);
});
and later on the doWork
function
var keys = $(dashboardID).getDataIDs();
for (var i = 0; i < keys.length; i++) {
var rowData = $(dashboardID).getRowData(keys[i]);
...
var reminderA = $(rowData.Alert_A).is(":checked");
var reminderB = $(rowData.Alert_B).is(":checked");
...
... other application logic here
}
Unfortunately I am experiencing the fact that the value of reminderA
and reminderB
variables does not reflect the exact state of the checkboxes but instead does always reflect the state of their initial values (e.g. when they have been loaded by the jqgrid plugin). In other words those values does'nt get updated when the user clicks on a checkbox in the grid.
Is this the right way to achieve my result or I have to use different code? Any help?
Thanks a lot!