限制剑道网格中的多项检查 [英] Restrict multiple checks in kendo grid

查看:120
本文介绍了限制剑道网格中的多项检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个kendo网格,复选框作为一个列。我想限制对此的多重检查。即用户必须只能检查一行,不能超过1个。



请帮助我。



编辑:

复选框是使用clientTemplate生成的。

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

感谢
Manikandan

解决方案

复选框并不相互排斥,因此您需要一些JavaScript代码才能获得所需的内容。



可以说你的电网识别是 grid 。您需要以下代码才能删除任何其他复选框。

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

我要做的是:


  1. 为任何具有类 chkbxq 的HTML input 定义处理函数。

  2. 获取已检查输入的状态。

  3. 将任何输入复选框设置为false chkbxq

  4. 最后,将选中输入的状态设置为该值。

问题:与您一起玩分页时,复选框状态不会持久可以在这里看到这种技术的一个运行示例: http://jsfiddle.net/OnaBai/eDu3k/2 /


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

解决方案

Checkboxes don't use to be mutually exclusive, so you need some JavaScript code for getting what you look for.

Lets say that your grid identification is grid. You would need the following code for removing any other checked box.

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

What I do is:

  1. Define a handler for any HTML input that has the class chkbxq.
  2. Get the status of the checked input.
  3. Set to false any input checkbox with class chkbxq
  4. Finally set the status of the checked input to the value. This is needed since we have removed it in the previous step.

Problem: Checkbox state is not persisted when you play with pagination as you can see in a running example of this technique here : http://jsfiddle.net/OnaBai/eDu3k/2/

这篇关于限制剑道网格中的多项检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆