简体   繁体   English

通过jquery设置Telerik网格客户端模板的属性复选框

[英]Set the Attribute of Telerik grid client template Check box through jquery

选择行后,我想更改Telerik网格客户端模板的属性(已选中)复选框。

You don't need to use JQuery for this as all the functionality you require is provided by the Telerik client side API. 您不需要为此使用JQuery,因为所需的所有功能都由Telerik客户端API提供。 I would start by adding a client side event handler to your RadGrid by adding something like the following to the markup: 我会通过将客户端事件处理程序到你的启动RadGrid通过添加类似下面的标记:

<ClientEvents OnRowSelected="jsRowSelected" />

The applicable Telerik documentation can then be used to determine what data you are passed to make this easier, in this instance the gridDataItem from here you can (hopefully) manipulate the row as follows: 然后可以使用适用的Telerik文档来确定传递哪些数据以gridDataItem此过程,在这种情况下,您可以(希望如此)从此处的gridDataItem如下操作该行:

function jsRowSelected(sender, eventArgs) {
    var cell = eventArgs.gridDataItem.get_cell("chkSelect"); // use the name of your column here
     var ctrls = cell.getElementsByTagName('input');
     if (ctrls .length > 0) {
         ctrls[0].checked = true; // I've got it setting the value to "checked" but you might want to do something else
     }
}

I've not syntax or error checked the above so in the (likely) event that it doesn't work the following functionality could be used to get the required item: The get_selectedItems method from the grids MasterTableView (see this guide ) allows you to get the selected data items; 我没有对以上内容进行语法或错误检查,因此在(可能)事件无法正常工作的情况下,可以使用以下功能来获取所需的项目:网格MasterTableViewget_selectedItems方法(请参见本指南 )允许您获取选择的数据项; from the selected row you can navigate to the column using getCellByColumnUniqueName method. 从选定的行,您可以使用getCellByColumnUniqueName方法导航到该列。 Here you could either look at using the findControl (see this guide ) or the previously mentioned getElementsByTagName as used above (looking for an input element) to find the checkbox control and update it's state. 在这里,您可以使用findControl (请参阅本指南 )或前面提到的getElementsByTagName如上所用)(查找input元素)来查找复选框控件并更新其状态。

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

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