Telerik网格 - 从复选框点击获取行 [英] Telerik grid - get row from checkbox click

查看:105
本文介绍了Telerik网格 - 从复选框点击获取行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿那里,

我有一个非常简单的情况,但显然遗漏了一些东西。



我有一个有3列的网格telerik radGrid。第一列是复选框 - 简单的asp复选框。我需要得到的是当我选中复选框时我需要从另一列获取值并将其存储在隐藏变量中。



任何人都有线索如何获取这样做了吗?



PS:我成功地点击了网格行:

Hey there,
I got a very simple situation but apparently missing something out.

I have a grid with 3 columns in telerik radGrid. 1st column is checkbox - simple asp checkbox. What I need to get is when I check the checkbox I need to take the value from another column and store it in hidden variable.

Anyone have a clue how to get this done?

P.S.: I succeeded to do the same with clicking on grid row with this:

var grid = sender;
var MasterTable = grid.get_masterTableView();
var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
var cell1 = MasterTable.getCellByColumnUniqueName(row, "RowUniqueName");





但这很简单,因为事件是在



But this was easy as the event was set in

<ClientEvents />





任何有关复选框的建议都将受到赞赏:)



谢谢!



Any suggestion about the checkbox would be appreciated :)

Thanks!

推荐答案

Telerik帮助页面: http://www.telerik.com/help/aspnet-ajax/grid-selecting-row-with-checkbox-server-side.html [ ^ ]

和一个演示: http://demos.telerik.com/aspnet-ajax/g rid / examples / functions / choices / row-selection / defaultcs.aspx [ ^ ]
The Telerik help page: http://www.telerik.com/help/aspnet-ajax/grid-selecting-row-with-checkbox-server-side.html[^]
And a demo: http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/selecting/row-selection/defaultcs.aspx[^]


Telerik文档很糟糕所以我发现了一种更好的方法代码:



Telerik documentation sucks so I found out a better way of doing this without writing tons of code:

<ItemTemplate>
    <asp:CheckBox

    ID="cb_Selected"

    Enabled="true"

    runat="server"

    onclick='<%# "cbClicked(\"" + Eval("ValuesFromDataSource") + "\", this);"/>
</ItemTemplate>



JS代码是这样的:


And the JS code would like this:

function cbClicked(key, chk) {
     // Key is the value I needed
     // chk is checkbox so I can check if it's checked or not chk.checked = True/False
}



所以 - 这是更清晰的代码,然后是telerik中的示例和演示。


So - this was way much cleaner code then examples and demos in telerik.


这篇关于Telerik网格 - 从复选框点击获取行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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