在radwindow中显示radgrid数据行的内容

时间:2013-09-05 04:34:30

标签: vb.net telerik radgrid radwindow

我在radwindow中显示所选radgrid行的数据时遇到问题。我尝试过使用此脚本双击客户端事件:

function RowDblClick(sender, eventArgs) { window.radopen("ViewForum.aspx?ForumID=" + eventArgs.getDataKeyValue("ForumID"), "RadWindow1");}

<ClientSettings>
       <Selecting AllowRowSelect="true"></Selecting>
       <ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
       <Scrolling AllowScroll="false" UseStaticHeaders="True" />
</ClientSettings>

基本上,我想要的只是当用户双击一行radgrid时,它会打开radwindow并显示他们选择的radgrid行的内容但我真的遇到了问题。如果我双击radgrid行,我可以打开radwindow,但问题是内容radwindow总是显示radgrid的第一行,即使我点击另一行也不会改变。提前谢谢。

1 个答案:

答案 0 :(得分:2)

enter image description here试试这段代码:

ASPX:

<telerik:RadGrid ID="grid1" runat="server" Width="200px" AutoGenerateEditColumn="true" AutoGenerateColumns="true" DataSourceID="SqlDataSource2">
<ClientEvents OnRowDblClick="OnRowDblClick" />
</ClientSettings>
</telerik:RadGrid>
<telerik:RadWindowManager ID="radwinmgr" runat="server">
  <Windows>
   <telerik:RadWindow ID="win1" runat="server">
    <ContentTemplate>
      ID: <asp:Label ID="Label1" runat="server"></asp:Label><br />
      Name:  <asp:Label ID="Label2" runat="server"></asp:Label>
     </ContentTemplate>
   </telerik:RadWindow>
 </Windows>
</telerik:RadWindowManager>

JS:

function OnRowDblClick(sender, eventArgs) {

        var grid = sender;
        var MasterTable = grid.get_masterTableView();
         var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
        var cell = MasterTable.getCellByColumnUniqueName(row, "EmployeeID"); // get the value by uniquecolumnname
        var FirstName = MasterTable.getCellByColumnUniqueName(row, "FirstName");
        var ID = cell.innerHTML;
        var name = FirstName.innerHTML;
        var win1 = $find("<%=win1.ClientID%>");
        var Label1 = document.getElementById("win1_C_Label1"); // accessing controls inside radwindow
        Label1.innerHTML = ID; // assigning the column value to the control inside radwindow
        var Label2 = document.getElementById("win1_C_Label2");
        Label2.innerHTML = name;
        win1.show();
    }

OR

如果您在radwindow open上重定向到另一个页面,请查看以下论坛链接。

How to make a rad window appear while double clicking a row in radgrid

这里我们将参数作为查询字符串传递并在页面加载中评估它。