限制剑道网格中的多项检查 [英] Restrict multiple checks in kendo grid
问题描述
我有一个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);
});
我要做的是:
- 为任何具有类
chkbxq
的HTMLinput
定义处理函数。 - 获取已检查输入的状态。
- 将任何输入复选框设置为false
chkbxq - 最后,将选中输入的状态设置为该值。
问题:与您一起玩分页时,复选框状态不会持久可以在这里看到这种技术的一个运行示例: 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:
- Define a handler for any HTML
input
that has the classchkbxq
. - Get the status of the checked input.
- Set to false any input checkbox with class
chkbxq
- 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屋!