This is a migrated thread and some comments may be shown as answers.

Window opening and RadGrid client side row selection

2 Answers 180 Views
Window
This is a migrated thread and some comments may be shown as answers.
Rod
Top achievements
Rank 1
Rod asked on 17 Feb 2009, 06:35 AM
Hi -

I have a RadGrid on a page displaying a list of orders, and a couple of buttons - external to the grid - to pop open RadWindows.  I'd like to be able to pass the Order ID from the selected row (using client-side row selection) in the grid to the query string for the RadWindow NavigateURL property by clicking one of the buttons.  I have looked at the example here: http://www.telerik.com/help/aspnet-ajax/window_programmingusingtheurlquerystring.html, which gives me part of the solution, but how can I reference the Order ID (which is the data key name for the grid)?  I would rather not use links or buttons in the grid itself since I am out of horizontal space - I would like to use the external buttons.

Also, using the example referenced above, I lost all of the window formatting specified in the RadWindowManager when the window popped open (width, height, behaviors, etc.). Do I need to set all of that up again in the JavaScript call to open the window, or is there a setting to have the JavaScript call pick up the info from within the RadWindoManager?

Thanks for the help,

Rod

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 17 Feb 2009, 10:23 AM
Hello Rod,

To access the datakeyvalue on the client, you have to set the ClientDataKeyNames property for the MasterTableView of the grid. You can check out the following code to pass the keyvalue to a window on a button click located outside the grid:
aspx:
 <asp:Button ID="btn1" runat="server" Text="GetSelectedItems" OnClientClick="return SelectItems();" /> 
    
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server">  
    <MasterTableView ClientDataKeyNames="OrderID">     
     .....      
     </MasterTableView>   
</telerik:RadGrid>  
  
<telerik:RadWindowManager ID="RadWindowManager1" Width="500px" Behaviors="Maximize,Move,Close" runat="server">  
</telerik:RadWindowManager>  

cs:
function SelectItems() 
{  
   var grid = $find("<%=RadGrid1.ClientID %>"); 
   var MasterTable = grid.get_masterTableView(); 
 
   var selectedRows = MasterTable.get_selectedItems(); 
   for (var i = 0; i < selectedRows.length; i++) 
   { 
     var row = selectedRows[i];      
     var keyvalue = row.getDataKeyValue("OrderID"); 
   } 
    
     var Wnd = radopen("Default2.aspx?KeyValue=" + keyvalue ,  "RadWindow1" ); 
     return false; 

Thanks
Princy.
0
Rod
Top achievements
Rank 1
answered on 17 Feb 2009, 09:28 PM
Princy - works like a charm.

Thanks,

Rod

Tags
Window
Asked by
Rod
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rod
Top achievements
Rank 1
Share this question
or