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

How to get Details table parent?

1 Answer 385 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gavin
Top achievements
Rank 1
Gavin asked on 25 Jul 2011, 04:02 PM
  I have a RadGrid with a DetailsTable... Inside the details table, I have a template column with a button.. I need to know which row in the original Grid does the details table of the clicked button belong too.... any ideas???

 (When I click Button2, I need to know which row in the original RadGrid that button belongs to)
   
<telerik:RadGrid ID="RadGrid1" AutoGenerateColumns="False" runat="server" AllowPaging="True" PageSize="10"
               Width="60%" GridLines="None" Skin="WebBlue"
               OnNeedDataSource="RadGrid1_NeedDataSource"
               OnItemCommand="RadGrid1_ItemCommand"
               OnDetailTableDataBind="RadGrid1_DetailTableDataBind"
               OnPrerender="RadGrid1_PreRender" >
               <MasterTableView ShowHeader="false" Width="100%">
                    <DetailTables>
                        <telerik:GridTableView Name="DetailsTable1" Width="100%"
                           ShowHeader="false" AutoGenerateColumns="false">
                            <Columns>
                              <telerik:GridTemplateColumn UniqueName="Column2">
                                   <ItemTemplate>
                                           <telerik:RadButton ID="Button2"
                                               runat="server"
                                               Text="Button2"
                                               OnClick="Button2_Click" />
                                   </ItemTemplate>
                               </telerik:GridTemplateColumn>
                            </Columns>
                        </telerik:GridTableView>
                    </DetailTables>
 
                   <Columns>
                      <telerik:GridTemplateColumn UniqueName="TemplateColumn">
                           <ItemTemplate>
                                           <telerik:RadButton ID="Button1"
                                               runat="server"
                                               Text="Button1"
                                               OnClick="Button1_Click" />
                           </ItemTemplate>
                       </telerik:GridTemplateColumn>
                   </Columns>
               </MasterTableView>
    </telerik:RadGrid>


  Thnx! Gavin

1 Answer, 1 is accepted

Sort by
0
Genti
Telerik team
answered on 25 Jul 2011, 04:33 PM
Hello Gavin,

Say that you have a reference to an item(the item object in my case) in the Detail table. Then in order to get the parent item you can do the following:

GridDataItem parentItem = (GridDataItem)(item.OwnerTableView.ParentItem);


Kind regards,
Genti
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Gavin
Top achievements
Rank 1
Answers by
Genti
Telerik team
Share this question
or