如何在Kendo网格中获取选定的单选按钮 [英] How to get the selected radio button in the Kendo Grid

查看:101
本文介绍了如何在Kendo网格中获取选定的单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Kendo网格,其中的一列由单选按钮组成. 我想使单选按钮充当单选按钮(仅选中1),然后选择1.

I have a kendo grid with a column consisting of radio buttons. I want to make the radio buttons act as radio buttons(check only 1) and get the selected 1.

以下是示例演示

推荐答案

您非常接近.首先是关于收音机的几件事:

You were pretty close. First a few things about radios:

  • 单选按钮使用name属性分组
  • 单选按钮通过标签元素上的for属性与单选按钮上的id属性匹配而绑定到标签
  • Radio buttons are grouped using the name attribute
  • Radio buttons are bound to labels via the for attribute on the label element matched with the id attribute on the radio button

您的代码存在的问题是所有单选按钮都具有相同的id,这就是为什么单击任何单选按钮会切换第一个按钮的原因...,因为假定找到了第一个具有该ID的元素, d只能是一个.

The problem with your code is that all radios have the same id, which is why clicking any radio button toggles the first one ... because the first element found with that id is grabbed, with the assumption that there'd only be one.

为了解决此问题,您需要为每个单选按钮使用唯一的ID,您可以通过使用#: EmployeeID#表示法引用数据源中的EmployeeID来做到这一点,如

In order to fix this, you need a unique id for each radio button, and you can do that by referencing the EmployeeID in the data source using the #: EmployeeID# notation, as exemplified in the docs

因此,您的模板应如下所示:

Therefore your template would look like this:

template: '<input type="radio" name="customer" id="customer_#: EmployeeID#" class="k-radio"><label class="k-radio-label" for="customer_#: EmployeeID#"></label>'

请在此处找到工作示例: https://dojo.telerik.com/aRuQubep/5

Please find working example here: https://dojo.telerik.com/aRuQubep/5

希望这能完成这项工作:)

Hope this does the job :)

这篇关于如何在Kendo网格中获取选定的单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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