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

Server side Expand All only expands first level in hierarchy

2 Answers 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve Newbery
Top achievements
Rank 1
Steve Newbery asked on 10 Nov 2008, 10:52 AM

I have added an Expand / Collapse All button to my RadGrid, which uses a 3-level hierarchy. Each level uses load mode ServerOnDemand. But the problem is that only the first level gets expanded.

I have adapted the CodeLibrary example http://www.telerik.com/community/code-library/aspnet-ajax/grid/expand-collapse-hierarchy-client-side-on-external-control-click.aspx

See below my adapted page - can anyone see why only the first level gets expanded? Even if I hard code item.Expanded = True it still doesn't work. 

Steve

 

<%@ Page EnableViewState="True" Language="VB" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<script runat="server">  
      
    Protected Sub ExpandCollapseButton_Click(ByVal sender As Object, ByVal e As EventArgs)  
        '-----------------------------------------------------------------------  
        ' Expand or Collapse all items in the grid  
        '-----------------------------------------------------------------------  
        For Each item As GridDataItem In RadGrid1.Items  
            item.Expanded = Not item.Expanded  
        Next  
    End Sub  
 
</script> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>Untitled Page</title> 
</head> 
<body style="margin: 0px;">  
    <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
        <div> 
 
            <asp:Button ID="ExpandCollapseButton" runat="server"   
                Text="Expand/Collapse All"   
                OnClick="ExpandCollapseButton_Click" /> 
 
            <telerik:RadGrid ID="RadGrid1" DataSourceID="AccessDataSource1" runat="server" Skin="WebBlue" 
                Width="95%" AutoGenerateColumns="False" PageSize="5" AllowSorting="True" AllowPaging="True" 
                GridLines="None">  
                <PagerStyle Mode="NumericPages"></PagerStyle> 
                <MasterTableView DataSourceID="AccessDataSource1" DataKeyNames="CustomerID" Width="100%" 
                    HierarchyLoadMode="ServerOnDemand">  
                    <DetailTables> 
                        <telerik:GridTableView DataKeyNames="OrderID" DataSourceID="AccessDataSource2" Width="100%" 
                            runat="server" HierarchyLoadMode="ServerOnDemand">  
                            <ParentTableRelation> 
                                <telerik:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" /> 
                            </ParentTableRelation> 
                            <DetailTables> 
                                <telerik:GridTableView DataKeyNames="OrderID" DataSourceID="AccessDataSource3" Width="100%" 
                                    runat="server" HierarchyLoadMode="ServerOnDemand">  
                                    <ParentTableRelation> 
                                        <telerik:GridRelationFields DetailKeyField="OrderID" MasterKeyField="OrderID" /> 
                                    </ParentTableRelation> 
                                    <Columns> 
                                        <telerik:GridBoundColumn SortExpression="UnitPrice" HeaderText="Unit Price" HeaderButtonType="TextButton" 
                                            DataField="UnitPrice" UniqueName="UnitPrice">  
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn SortExpression="Quantity" HeaderText="Quantity" HeaderButtonType="TextButton" 
                                            DataField="Quantity" UniqueName="Quantity">  
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn SortExpression="Discount" HeaderText="Discount" HeaderButtonType="TextButton" 
                                            DataField="Discount" UniqueName="Discount">  
                                        </telerik:GridBoundColumn> 
                                    </Columns> 
                                </telerik:GridTableView> 
                            </DetailTables> 
                            <Columns> 
                                <telerik:GridBoundColumn SortExpression="OrderID" HeaderText="OrderID" HeaderButtonType="TextButton" 
                                    DataField="OrderID" UniqueName="OrderID">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn SortExpression="OrderDate" HeaderText="Date Ordered" HeaderButtonType="TextButton" 
                                    DataField="OrderDate" UniqueName="OrderDate">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn SortExpression="EmployeeID" HeaderText="EmployeeID" HeaderButtonType="TextButton" 
                                    DataField="EmployeeID" UniqueName="EmployeeID">  
                                </telerik:GridBoundColumn> 
                            </Columns> 
                        </telerik:GridTableView> 
                    </DetailTables> 
                    <Columns> 
                        <telerik:GridBoundColumn SortExpression="CustomerID" HeaderText="CustomerID" HeaderButtonType="TextButton" 
                            DataField="CustomerID" UniqueName="CustomerID">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn SortExpression="ContactName" HeaderText="Contact Name" HeaderButtonType="TextButton" 
                            DataField="ContactName" UniqueName="ContactName">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn SortExpression="CompanyName" HeaderText="Company" HeaderButtonType="TextButton" 
                            DataField="CompanyName" UniqueName="CompanyName">  
                        </telerik:GridBoundColumn> 
                    </Columns> 
                </MasterTableView> 
                <ClientSettings AllowExpandCollapse="true">  
                </ClientSettings> 
            </telerik:RadGrid> 
            <asp:AccessDataSource ID="AccessDataSource1" DataFile="~/Grid/Data/Access/Nwind.mdb" 
                SelectCommand="SELECT * FROM Customers" runat="server"></asp:AccessDataSource> 
            <asp:AccessDataSource ID="AccessDataSource2" DataFile="~/Grid/Data/Access/Nwind.mdb" 
                SelectCommand="SELECT * FROM Orders Where CustomerID = ?" runat="server">  
                <SelectParameters> 
                    <asp:SessionParameter Name="CustomerID" SessionField="CustomerID" Type="string" /> 
                </SelectParameters> 
            </asp:AccessDataSource> 
            <asp:AccessDataSource ID="AccessDataSource3" DataFile="~/Grid/Data/Access/Nwind.mdb" 
                SelectCommand="SELECT * FROM [Order Details] where OrderID = ?" runat="server">  
                <SelectParameters> 
                    <asp:SessionParameter Name="OrderID" SessionField="OrderID" Type="Int32" /> 
                </SelectParameters> 
            </asp:AccessDataSource> 
        </div> 
    </form> 
</body> 
</html> 
 

2 Answers, 1 is accepted

Sort by
0
Steve Newbery
Top achievements
Rank 1
answered on 10 Nov 2008, 02:25 PM
I have raised a support ticket for this, as it's a bit urgent - the application is due to go live tomorrow (gulp!).

Steve
0
Yavor
Telerik team
answered on 12 Nov 2008, 11:21 AM
Hello Steve,

The support ticket that you have opened on the matter has been addressed. We an can continue our communication there, to avoid duplicate posts.

Best wishes,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Steve Newbery
Top achievements
Rank 1
Answers by
Steve Newbery
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or