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

Nested RadGrid on RadGrid Column Button Click

3 Answers 251 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kanchan
Top achievements
Rank 1
kanchan asked on 20 Feb 2014, 01:28 PM
Hi,

I want to know is it possible to show nested Grid on click of button in parent table.
I would appreciate if any source code example is there.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Feb 2014, 04:18 AM
Hi Kanchan,

You can add a GridButtonColumn to thr Grid, set its CommandName, access it in the ItemCommand event and write code to expand the row.

ASPX:
<telerik:GridButtonColumn Text="Expand" UniqueName="Expand" CommandName="Expand">
</telerik:GridButtonColumn>

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
  if (e.CommandName == "Expand")
  {
   GridDataItem item = (GridDataItem)e.Item;
   item.Expanded = true;
  }
}

thanks,
Princy
0
Kanchan
Top achievements
Rank 1
answered on 21 Feb 2014, 04:39 AM
Hi,

I have two level nested grid.
On Parent Table Item click show child grid. On Click of Item in child Grid further expand to child grid  as shown in .Png Image file in attachment above.
0
Princy
Top achievements
Rank 2
answered on 21 Feb 2014, 05:32 AM
Hi Kanchan,

You can use the same GridButtonColumn in both the inner grids and access parent ItemCommand event with the same CommandName.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" OnItemCommand="RadGrid1_ItemCommand">
    <MasterTableView >
        <Columns>
            <telerik:GridButtonColumn Text="Expand" UniqueName="Expand" CommandName="Expand">
            </telerik:GridButtonColumn>
        </Columns>
        <NestedViewTemplate>
            <telerik:RadGrid ID="RadGrid2" runat="server" OnItemCommand="RadGrid1_ItemCommand">
                <MasterTableView>
                    <Columns>
                        <telerik:GridButtonColumn Text="Expand" UniqueName="Expand" CommandName="Expand">
                        </telerik:GridButtonColumn>
                    </Columns>
                    <NestedViewTemplate>
                        Inner Grid
                    </NestedViewTemplate>
                </MasterTableView>
            </telerik:RadGrid>
        </NestedViewTemplate>
    </MasterTableView>
</telerik:RadGrid>

Thanks,
Princy
Tags
Grid
Asked by
kanchan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kanchan
Top achievements
Rank 1
Share this question
or