简体   繁体   English

在包含复选框的MVC Kendo网格上禁用单击事件

[英]Disable click event on mvc kendo grid containing checkbox

I have column holding the checkbox on a MVC kendo grid. 我在MVC剑道网格上保留了该复选框的列。 When I click on the column but not on the checkbox, the checkbox position is slipping (moving towards right) and the click event is not delegating to checkbox. 当我单击列而不是复选框时,复选框的位置正在滑移(向右移动),而click事件并未委托给复选框。

I tried Change event and DataBound to suppress the click even on column but couldn't do it. 我尝试了Change event和DataBound来抑制甚至在列上的单击,但无法执行。

Any suggestions to disable the click event on this Kendo Grid checkbox-column or to delegate the column's click event to checkbox ! 关于禁用此Kendo Grid复选框框中 的click事件将列的click事件委托给checkbox的任何建议!

Below is the code snippet that I have used to build the checkbox column, 以下是我用来构建复选框列的代码段,

columns.Bound(p => p.IsSelected).Title("Select").Width(11).ClientTemplate("<input type='checkbox' #= (IsSelected) ? checked='checked' : '' #  id=chk#=(Id)#  class='exclchkbx' />").HtmlAttributes(new { style = "text-align: center;" }).Width(10).HeaderHtmlAttributes(new { style = "text-align:center;" });



Output of my grid column 我的网格列的输出

在此处输入图片说明

Dislocated checkbox after clicking the checkbox column (but not on checkbox) 单击复选框列后出现错位的复选框(但不在复选框上)

在此处输入图片说明

Appreciated in advance! 预先赞赏!

The reason why the checkbox position is slipping is that there is default padding applied. 复选框位置滑动的原因是应用了默认填充。 Instead of using the HeaderHtmlAttributes method, you can wrap up the template in a div with text-center as follows: 代替使用HeaderHtmlAttributes方法,可以将模板包装在具有text-center的div中,如下所示:

            columns.Bound(p => p.IsSelected).Title("Select").Width(11).ClientTemplate("<div class=\"text-center\"><input type='checkbox' #= (IsSelected) ? checked='checked' : '' #  id=chk#=(Id)#  class='exclchkbx' /></div>");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM