Hi,
I was wondering if anyone could tell me how to do this. I need an image button in a details record of a radgrid to cause a radwindow to open when it's clicked. I think I need to assign the right attibrute to the control in the item created event, but I'm not sure how to do this?
Thanks
I was wondering if anyone could tell me how to do this. I need an image button in a details record of a radgrid to cause a radwindow to open when it's clicked. I think I need to assign the right attibrute to the control in the item created event, but I'm not sure how to do this?
Thanks
4 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 16 Feb 2009, 02:22 PM
Hello William,
You can try out the following code to open a RadWindow on clicking an ImageButton in a row in the detail table :
aspx:
cs:
js:
Thanks
Princy.
You can try out the following code to open a RadWindow on clicking an ImageButton in a row in the detail table :
aspx:
| <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" > |
| <MasterTableView DataSourceID="SqlDataSource1" Name="Master"> |
| <DetailTables> |
| <telerik:GridTableView DataSourceID="SqlDataSource2" DataKeyNames="ProductName" Name="Detail1" > |
| </DetailTables> |
| <Columns> |
| </telerik:GridBoundColumn> |
| <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/Image.bmp" UniqueName="ButtonColumn" HeaderText="ButtonColumn" ></telerik:GridButtonColumn> |
| </Columns> |
| </telerik:GridTableView> |
| </DetailTables> |
cs:
| protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Detail1") //access the detail table using Name property |
| { |
| GridDataItem dataItem = (GridDataItem)e.Item; |
| ImageButton imgbtn = (ImageButton)dataItem["ButtonColumn"].Controls[0]; |
| imgbtn.Attributes["onclick"] = String.Format("return ShowDetails('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ProductName"], e.Item.ItemIndex); |
| } |
| } |
js:
| function ShowDetails(id, rowIndex) |
| { |
| var grid = $find("<%= RadGrid1.ClientID %>"); |
| var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element(); |
| grid.get_masterTableView().selectItem(rowControl, true); |
| window.radopen("Details.aspx?ProductName=" + id, "Details"); |
| return false; |
Thanks
Princy.
0
William
Top achievements
Rank 1
answered on 17 Feb 2009, 02:59 PM
Excellent! That's what I was looking for. Thanks Princy
0
Princy
Top achievements
Rank 2
answered on 18 Feb 2009, 06:21 AM
Hi William,
You can also refer to the following demo which demonstrates on how to open a window and populate it with the grid row details, on clicking a button in the row:
Window Editing
-Princy
You can also refer to the following demo which demonstrates on how to open a window and populate it with the grid row details, on clicking a button in the row:
Window Editing
-Princy
0
William
Top achievements
Rank 1
answered on 18 Feb 2009, 04:58 PM
Thanks Princy.