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

[Solved] expand all hierarchy items from server side

1 Answer 341 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erwin Floresca
Top achievements
Rank 1
Erwin Floresca asked on 17 Mar 2010, 09:09 PM
Hi,

I am trying to expand all the hierarchy items in the grid from the server side. I was able to expand the mastertableview rows to display the detail table. Each row in the detail table can expand to display the nested view. I am not able to get these rows expanded. Below is my aspx code for the grid

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" Width="700px"  
            AllowMultiRowSelection="true"
            <MasterTableView HierarchyLoadMode="ServerBind" GroupLoadMode="Server" Width="700px"  
                DataKeyNames="ActionId" TableLayout="Fixed" Name="Actions" CommandItemDisplay="Top"
                <CommandItemTemplate> 
                    <asp:Button ID="btnExpandOrCollapse" runat="Server" Text="Expand or Collapse" CommandName="expandallcollapseall" /> 
                </CommandItemTemplate>                 
                <Columns> 
                    <telerik:GridBoundColumn DataField="ActionName" HeaderText="Action"></telerik:GridBoundColumn> 
                    <telerik:GridTemplateColumn> 
                        <ItemTemplate> 
                            <telerik:RadRating ID="RadRating1" runat="server" Value="3" ReadOnly="true" Precision="Exact" /> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                </Columns> 
                <DetailTables>                     
                    <telerik:GridTableView DataKeyNames="StepId" Name="Steps" Width="100%"
                        <ParentTableRelation> 
                            <telerik:GridRelationFields DetailKeyField="ActionId" MasterKeyField="ActionId" /> 
                        </ParentTableRelation> 
                        <Columns> 
                            <telerik:GridBoundColumn DataField="StepName" HeaderText="Step" DefaultInsertValue="" UniqueName="StepName"></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="StartDate" HeaderText="Start date" DefaultInsertValue="" UniqueName="StartDate"></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="StartedBy" HeaderText="Completed by" DefaultInsertValue="" UniqueName="StartedBy"></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="HRApproval" HeaderText="HR Approval" DefaultInsertValue="" UniqueName="HRApproval"></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="CommunicatedToEE" HeaderText="Communicated to employee" DefaultInsertValue="" UniqueName="Communicatedtoee"></telerik:GridBoundColumn> 
                        </Columns>           
                        <NestedViewTemplate> 
                        <asp:Panel ID="pnlTesting" runat="server"
                            <div style="width:25px;float:left"></div> 
                            <div style="float:left;"
                                <asp:HiddenField ID="hStepId" runat="Server" Value='<%# DataBinder.Eval(Container.DataItem, "StepId") %>' /> 
                                <uc1:QuestionAndAnswerV1 ID="qa" runat="server" Skin="QAList" EnableEmbeddedSkins="false" /> 
                            </div>                         
                        </asp:Panel>                                                                   
                        </NestedViewTemplate>                         
                    </telerik:GridTableView>                     
                </DetailTables>                                 
                <ExpandCollapseColumn Visible="True"
                </ExpandCollapseColumn> 
            </MasterTableView> 
            <ClientSettings> 
                <Scrolling SaveScrollPosition="true" /> 
            </ClientSettings> 
        </telerik:RadGrid> 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Mar 2010, 09:02 AM
Hi,

Please try  setting the HierarchyDefualtExpanded to true fro all the OwnerTableView as shown below:

C#
RadGrid1.MasterTableView.HierarchyDefaultExpanded = true
RadGrid1.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true
RadGrid1.Rebind(); 

Princy
Tags
Grid
Asked by
Erwin Floresca
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or