我正在使用 KendoUI 进行 MVC。我使用 RadioButtonFor 帮助器创建了一些 RadioButtons。所有 KendoUI 都有一个 JavaScript Controller ,用于管理您可以访问的每个控件的客户端方面。
例如:MVC 网格助手
// MVC HELPER
@(Html.Kendo().Grid<SomeDataItem>().Name("SomeGrid") ...other stuff... )
// Grid
var control = $('#SomeGrid')).data('kendoGrid')
...now I can use "control" to set events or do othjer things for the Grid.
我需要:
我需要为 RadioButton 控件客户端设置一些事件和其他内容。
// MVC HELPER
@(Html.Kendo().RadioButtonFor(model => model.Entity.Meter.FlowTypeId)
.Label("Initial")
.Value(1))
@(Html.Kendo().RadioButtonFor(model => model.Entity.Meter.FlowTypeId)
.Label("Reconnect/Resumed")
.Value(2))
问题:
如何访问这些单选按钮的“Kendo UI Control”?
正常方法不起作用: $('#Entity_Meter_FlowTypeId_1').data() //<-- empty
...这通常会给您一个数据内容列表。
最佳答案
Kendo 没有用于单选按钮的客户端 API。
这是因为它只是一个带有标签的单选按钮,因此除了普通的 javascript 事件之外,没有可以绑定(bind)的自定义事件。您可以使用 javascript/jquery 绑定(bind)到这些事件,因此将这些相同的事件添加到 kendo 对象中没有实际意义。
设置属性也受到限制(文本/选中/?),并且这些可以再次使用普通 JS 轻松处理。
您唯一能做的就是设置单选按钮的样式,如 the Telerik site 中所述。 .
关于javascript - 访问 Kendo UI MVC RadioButtonFor Helper 的 JavaScript 控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47358617/