Reputation: 227
I would like to have my checkbox column operate as if it were a group, ie I can only check a single check box and if I select a different one all other check boxes will be unchecked.
Below is my grid.
colNames: ['PSN', 'Program Name', 'Comp. Year', 'Primary', 'Select'],
colModel: [
{ name: 'PSN', index: 'PSN', width: 5, sortable: false, search: false, align: 'center', editable: false },
{ name: 'ProgramName', index: 'ProgramName', width: 40, sortable: false, search: false, align: 'left', editable: false },
{ name: 'CompletedYear', index: 'CompletedYear', width: 10, sortable: false, search: false, align: 'left', editable: false },
{ name: 'PrimaryPSN', index: 'PrimaryPSN', width: 10, sortable: false, search: false, align: 'center', editable: false }, // ,formatter: PrimaryPSN,
{ name: 'SurveyPSN', index: 'SurveyPSN', width: 10, sortable: false, search: false, align: 'center', editable: true, edittype: 'checkbox', editoptions: { value: "True:False" }, formatter: 'checkbox', formatoptions: { disabled: false } }, //
],
cellEdit:true,
I have thought about adding an afterEdit event but don't know about looping through the grid to clear anyother checked cells.
Upvotes: 0
Views: 649
Reputation: 354
You can do this by writing you custom function and giving a class to check box and a particular ID.
{ name: 'Action', index: 'Action', width: 80, align: 'center', formatter: function (cell, options, obj) { return "<input type ='checkbox' class='getcheckbox' id ='chkReviewed_" + ID + "' onclick='SelectedId(" + ID + ")'/>" }}
Now in this "SelectedId(ID)" function you can unchecked all the check box based on class and then select the particular check box based on ID.
Hope this will solve you problem
Upvotes: 3