0

I have a kendo grid, with checkboxes as a column. I want to restrict multiple checks on this. i.e. User must be able to check only one row, not more than 1.

Please help me on this.

Edit:

The checkboxes are generated using clientTemplate. I have bounded the column with the grid.

     columns.Bound(p => p.FlightNo).HeaderTemplate(" ")
    .ClientTemplate("<input id='checkbox' name='chbox' class='chkbxq' type='checkbox' />").Sortable(false).Filterable(false).Width(50);

Thanks Manikandan

4

1 回答 1

3

复选框过去不是相互排斥的,因此您需要一些 JavaScript 代码来获取您要查找的内容。

假设您的网格标识是grid. 您需要以下代码来删除任何其他复选框。

$("#grid").on("change", "input.chkbxq", function (e) {
    var v = $(this).is(":checked");
    $("input.chkbxq", "#grid").prop("checked", false);
    $(this).prop("checked", v);
});

我要做的是:

  1. input为任何具有 class 的HTML 定义处理程序chkbxq
  2. 获取检查输入的状态。
  3. 将任何带有类的输入复选框设置为 falsechkbxq
  4. 最后将检查输入的状态设置为值。这是必需的,因为我们在上一步中已将其删除。

问题:当您使用分页时,复选框状态不会持续存在,正如您在此技术的运行示例中所见:http: //jsfiddle.net/OnaBai/eDu3k/2/

于 2013-06-19T18:12:04.167 回答