我想让我的复选框列像是一组一样运行,即,我只能选中一个复选框,如果我选择了另一个复选框,则所有其他复选框都将被取消选中。
下面是我的网格。
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,
我曾考虑过添加一个afterEdit事件,但不知道循环遍历网格以清除任何其他检查的单元格。
您可以通过编写自定义函数并为复选框提供一个类和特定的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 + ")'/>" }}
现在,在此“ SelectedId(ID)”函数中,您可以取消选中所有基于类的复选框,然后选择基于ID的特定复选框。
希望这能解决您的问题
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句