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

Colapsed sign

2 Answers 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Omlac
Top achievements
Rank 1
Omlac asked on 20 Oct 2008, 06:51 AM
Hi
I have got a hierarchy grid which im populating its detailview programatically. I would like to make a collapse sign(+) appear when ever a row has a subrow underneath. Does anyone know how to do this(Rigth now its only appearing when i click the row).

Thank you.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Oct 2008, 06:36 AM
Hi,

You need to set HierarchyDefaultExpanded to true in the MasterTableView definition and then write the following code snippet to prevent items with no child records from collapsing
CS:
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
        { 
            foreach (GridDataItem item in RadGrid1.Items) 
            { 
                GridTableView nestedTableView = (RadGrid1.MasterTableView.Items[item.ItemIndex] as GridDataItem).ChildItem.NestedTableViews[0]; 
                
                if (nestedTableView.Items.Count == 0) 
                    item.Expanded = false
                else 
                    item.Expanded = true
                 
            } 
 
            
        } 

Thanks,
Shinu
0
Omlac
Top achievements
Rank 1
answered on 21 Oct 2008, 09:31 AM
Hie Shinu, when i don't specify a skin type the + signs appear but when i do specify the signs disappear even though the collapse and expand appear as required.Currently im using the Skin="Office2007"

and the rest of my code html is as follows:
<telerik:RadGrid ID="RadGrid2" runat="server" Skin="Office2007"Width="100%" SelectedItemStyle-BackColor ="ActiveBorder" OnColumnCreated="RadGrid2_ColumnCreated"OnNeedDataSource="RadGrid2_NeedDataSource" AllowSorting="True" AllowPaging="True" GridLines="None" Height="100%" OnItemCommand="RadGrid2_ItemCommand" OnItemDataBound="RadGrid2_ItemDataBound" OnPreRender="RadGrid2_PreRender" ShowHeader="False" ShowStatusBar="True">
<MasterTableView HierarchyDefaultExpanded="true" HierarchyLoadMode="Client" DataKeyNames="LocationID,ParentLocationID" Width="100%"> <SelfHierarchySettings ParentKeyName="ParentLocationID" KeyName="LocationID" MaximumDepth="100" /><NoRecordsTemplate></NoRecordsTemplate> </MasterTableView>
 <ClientSettings EnableRowHoverStyle="True"><Selecting AllowRowSelect="True" /><Scrolling AllowScroll="True" UseStaticHeaders="True" /> </ClientSettings>
<PagerStyle Mode="NextPrevAndNumeric" />
<SelectedItemStyle BackColor="ActiveBorder" /></telerik:RadGrid>

 

Tags
Grid
Asked by
Omlac
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Omlac
Top achievements
Rank 1
Share this question
or