We have a 4 layer hierarchy RADGrid (1 - MasterTableView and 3 GridTableViews). On each layer there are 4 asp:LinkButtons(Divisions, Sites, Accounts, and Fiscal Year). We want to expand or collapse the RADGrid by clicking on either the ExpandCollapseColumn or the asp:LinkButton. For example we want the user to be able to click (or double-click) on the Division or the <ExpandCollapseColumn> (MasterTableView) and they would see the Sites (The first GridTableView). If they click it again it should collapse the Sites. We currently handle the OnDetailTableDataBind, OnItemCommand, and OnNeedDataSource events. We are using advanced data-binding methods (NeedDataSource and DetailTableDataBind) and these are working correctly. We are able to get the DataKeyValue in the ItemCommand. Can anyone provide some assistance on how to do this?
6 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 06 Mar 2009, 10:43 AM
Hi Darrell,
From what I understood so far you are trying to expand/collapse the Grid rows on clicking a LinkButton in a row in addition to the expand/collapse column. If so you can try the following approach. Here I have implemented the desired scenario with a linkbutton in a GridTemplateColumn.
ASPX:
CS:
Thanks
Princy.
From what I understood so far you are trying to expand/collapse the Grid rows on clicking a LinkButton in a row in addition to the expand/collapse column. If so you can try the following approach. Here I have implemented the desired scenario with a linkbutton in a GridTemplateColumn.
ASPX:
<telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol" > |
<ItemTemplate> |
<asp:LinkButton ID="LinkButton1" CommandName="ExpandCol" runat="server">Click</asp:LinkButton> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
CS:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == "ExpandCol") |
{ |
e.Item.Expanded = !e.Item.Expanded; |
} |
} |
Thanks
Princy.
0
Darrell
Top achievements
Rank 1
answered on 06 Mar 2009, 01:40 PM
Thanks
This worked great!
This worked great!
0
Darrell
Top achievements
Rank 1
answered on 06 Mar 2009, 07:42 PM
Thanks, your solution works great but we have added some additional requirements or functionality to this problem.
We have a 4 layer hierarchy RADGrid (1 - MasterTableView and 3 GridTableViews). On each layer there are 4 asp:LinkButtons(Divisions, Sites, Accounts, and Fiscal Year). We are able expand or collapse the RADGrid by clicking on either the ExpandCollapseColumn or the asp:LinkButtons. We have added a second Detail Table ("DivisionDetail") under the MasterTableView. It does not have any child tables. If we click the Division, Site, or Account LinkButtions we want to expand or collapse the orginal 3 GridTableViews. if we click the Fiscal Year LinkButton, we want to expand only the new DivisionDetail GridTableView. We have reviewed the demo "Several Tables at a Level" but this does not seem to work for us.
Can you provide some additional assistance?
Can you provide some additional assistance?
0
Shinu
Top achievements
Rank 2
answered on 09 Mar 2009, 08:22 AM
Hi Darrell,
I guess you are having several child tables at the same level and you are trying to hide the rest of the Detail tables other than the 'DivisionDetail' while expanding the Grid using linkbutton named 'Fiscal Year'. If so you can try the following approach and see if it helps
ASPX:
Note: set the Name property for the Detail table
CS:
Thanks
Shinu
I guess you are having several child tables at the same level and you are trying to hide the rest of the Detail tables other than the 'DivisionDetail' while expanding the Grid using linkbutton named 'Fiscal Year'. If so you can try the following approach and see if it helps
ASPX:
<telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol" > |
<ItemTemplate> |
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="ExpandItem" >Divisions</asp:LinkButton> |
<asp:LinkButton ID="LinkButton3" runat="server" CommandName="ExpandItem" >Sites</asp:LinkButton> |
<asp:LinkButton ID="LinkButton4" runat="server" CommandName="ExpandItem" >Accounts</asp:LinkButton> |
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Fiscal Year" >Fiscal Year</asp:LinkButton> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
Note: set the Name property for the Detail table
<DetailTables> |
<telerik:GridTableView Name="Detail1" AutoGenerateColumns="false" runat="server" DataSourceID="SqlDataSource1" > |
<Columns> |
<telerik:GridBoundColumn UniqueName="ProductName" DataField="ProductName" HeaderText="ProductName" ></telerik:GridBoundColumn> |
</Columns> |
</telerik:GridTableView> |
<telerik:GridTableView Name="Detail2" runat="server" AutoGenerateColumns="false" DataSourceID="SqlDataSource2" > |
<Columns> |
<telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" ></telerik:GridBoundColumn> |
</Columns> |
</telerik:GridTableView> |
<telerik:GridTableView Name="Detail3" runat="server" AutoGenerateColumns="false" DataSourceID="SqlDataSource3" > |
<Columns> |
<telerik:GridBoundColumn UniqueName="StarDate" DataField="StarDate" HeaderText="StarDate" ></telerik:GridBoundColumn> |
</Columns> |
</telerik:GridTableView> |
</DetailTables> |
CS:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == "Fiscal Year") |
{ |
e.Item.Expanded = !e.Item.Expanded; |
if (e.Item.Expanded) |
{ |
GridDataItem item=(GridDataItem)e.Item; |
foreach (GridTableView childTable in item.ChildItem.NestedTableViews) |
{ //hide the child table depending on the Name property |
if (childTable.Name != "Detail3") |
childTable.Visible = false; |
} |
} |
} |
else if (e.CommandName == "ExpandItem") |
{ |
e.Item.Expanded = !e.Item.Expanded; |
} |
} |
Thanks
Shinu
0
Darrell
Top achievements
Rank 1
answered on 10 Mar 2009, 12:42 PM
I have 1 more question (I promise this is the last). Using the same 4 layer hierarchy RADGrid (1 - MasterTableView and 3 GridTableViews), we want to display all of the Divisions (MasterTableView) and all of the corresponding Sites (1st GridTableView) for each Division. On each layer there are 4 asp:LinkButtons(Divisions, Sites, Accounts, and Fiscal Year). We want the Grid to look like the following:
Division 1
Site 1 (for Division 1)
Site 2 (for Division 2)
Site 3 (for Division 3)
Division 2
Site 1 (for Division 2)
Site 2 (for Division2)
We currently load the Divisions using the OnNeedDataSource and we expand the Divisions to show the Sites using the OnDetailTableDataBind. We use two separate stored procedures to bring back the information. On each layer there are also 4 asp:LinkButtons(Divisions, Sites, Accounts, and Fiscal Year). We can expand each MasterTableView and/or each GridTableView by clicking on either ExpandCollapseColumn or the asp:LinkButton (via setting the Expanded property).
Division 1
Site 1 (for Division 1)
Site 2 (for Division 2)
Site 3 (for Division 3)
Division 2
Site 1 (for Division 2)
Site 2 (for Division2)
We currently load the Divisions using the OnNeedDataSource and we expand the Divisions to show the Sites using the OnDetailTableDataBind. We use two separate stored procedures to bring back the information. On each layer there are also 4 asp:LinkButtons(Divisions, Sites, Accounts, and Fiscal Year). We can expand each MasterTableView and/or each GridTableView by clicking on either ExpandCollapseColumn or the asp:LinkButton (via setting the Expanded property).
We have combined the stored procedure to get the Divisions and the stored procedure to get the Sites into 1 stored procedure that gets both Divisions and Sites.
Can you provide some assistance on how to accomplish this?
Can you provide some assistance on how to accomplish this?
0
Darrell
Top achievements
Rank 1
answered on 10 Mar 2009, 02:53 PM
i forgot to mention that we have combined the stored procedure to get the Divisions and the stored procedure to get the Sites into 1 stored procedure that gets both Divisions and Sites.