Question

I'm having a problem in showing the data of selected row of radgrid in radwindow. What I have tried is using double click on client event using this script:

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>

Basically, all I want is whenever a user double click on a row of radgrid, it will open the radwindow and show the contents of the radgrid row that they have selected but I'm really having problem doing that. I can open the radwindow if I double click on the row of radgrid but the problem is the content radwindow always shows the first row of radgrid, it doesn't change even if I click on a different row. Thank you in advance.

Was it helpful?

Solution

enter image description hereTry this code:

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

If you are redirecting to another page on radwindow open then take a look into the following the forum link.

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

Here we are passing the parameter as query string and assessing that in page load.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top