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

nestedviewtemplate expanded

9 Answers 727 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cres
Top achievements
Rank 1
Cres asked on 17 Jul 2008, 02:44 AM
hello community,

is there a way so that my nestedviewtemplate is expanded by default?  related question is how can i expand and collapse all nestedview items.

thanks in advance!
-cris

9 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Jul 2008, 04:32 AM
Hi Chris,

Try setting HierarchyDefaultExpanded property to true to expand all the nestedview items by default.

ASPX:
  <MasterTableView HierarchyDefaultExpanded="true"   > 
                 

You can also refer the following code library submission which explains how to implement ExpandAll/CollapseAll functionality with Grid hierarchy.
Custom expand/collapse column with ExpandAll/CollapseAll image button in the header

Thanks
Shinu.
0
Cres
Top achievements
Rank 1
answered on 17 Jul 2008, 05:39 AM
hello shinu,

both approach did not expand my rows.  maybe, my radgrid is not grouped that is why hierarchy functions does not work.  as i trace the item.canexpanded is always false. any other ideas?

-cris

<telerik:RadGrid ID="CATE_rg" runat="server" DataSourceID="CATE_lds" OnItemDataBound="CateItemBound" 
    AllowPaging="True" GridLines="None" AutoGenerateColumns="False" ShowHeader="false" OnPreRender=CatePreRender>  
    <MasterTableView DataSourceID="CATE_lds" DataKeyNames="recgid" HierarchyDefaultExpanded="true">  
        <Columns> 
            <telerik:GridTemplateColumn> 
                <ItemStyle Font-Bold="true" Font-Size="Larger" /> 
                <ItemTemplate> 
                    <%# Eval("NAME") %> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
        </Columns> 
        <NestedViewTemplate> 
            <asp:TextField ID="NAME_hf" Text='<%# Eval("NAME") %>' runat="server" /> 
            <br />show as expanded fails...  
        </NestedViewTemplate> 
        <CommandItemTemplate> 
        </CommandItemTemplate> 
    </MasterTableView> 
</telerik:RadGrid> 

   protected void CatePreRender(object sender, EventArgs e)  
    {  
        //Hiding the default expand/collapse image      
        foreach (GridItem item in CATE_rg.MasterTableView.Controls[0].Controls)  
        {  
            if (item is GridNestedViewItem)  
                  item.Expanded = true;  
            
        }  
 
    }   
0
Princy
Top achievements
Rank 2
answered on 17 Jul 2008, 06:30 AM
Hi Chris,

Can you try setting the HierarchyDefaultExpanded property in the PreRender event and see whether it working .

CS:
 protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;  
        RadGrid1.Rebind();  
    } 


Thanks
Princy
0
Cres
Top achievements
Rank 1
answered on 17 Jul 2008, 08:23 AM
hi princy,

expansion does not work entirely, i think, rebinding during prerenders resets the viewstate??? anyway, i will try to set the hierarchydefaultexpanded in other possible grid events.

telerik team,
any ideas? or should i file a ticket now?

best,
-cris
0
Daniel
Telerik team
answered on 17 Jul 2008, 03:30 PM
Hi Cris,

We made a sample website for your convenience and it illustrates the needed approach. Please find it attached to this post.

Additionally the same effect can be achieved by the following code-snippet:
public partial class _Default : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        RadGrid1.MasterTableView.HierarchyDefaultExpanded = true
        foreach (GridTableView gtv in RadGrid1.MasterTableView.DetailTables) 
            gtv.HierarchyDefaultExpanded = true
    } 

Greetings,
Daniel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Cres
Top achievements
Rank 1
answered on 20 Jul 2008, 05:41 AM
hi daniel,

thank you for taking some time to create a sample that works, but my requirement is a nestedview under the mastertableview as indicated in the code that i posted. my requirement is much simpler and is based on the detailtemplate example for ajax radgrids.

thanks again and will wait for your help.

-cris
0
Daniel
Telerik team
answered on 21 Jul 2008, 02:55 PM
Hi Cris,

I made an example based on the Detail template demo and I also configured it to expand as you desired.

Please let me know whether this helps.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Cres
Top achievements
Rank 1
answered on 10 Aug 2008, 03:11 PM
hi daniel,

sorry, weve been very busy for past few weeks, its just this time that i started looking again at this.  forgot to tell the forum that my grid is a user control, so most calls does not work, what event should i set the flags then?

-cris
0
Daniel
Telerik team
answered on 13 Aug 2008, 02:27 PM
Hello Cris,

What do you mean by 'flag'? I suppose you are wondering how to set the Hierarchy to expanded when your RadGrid resides in user control.
(UserGrid1.FindControl("RadGrid1"as RadGrid).MasterTableView.HierarchyDefaultExpanded = true

The code above can be inserted in your Page_Load event.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Cres
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Cres
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Daniel
Telerik team
Share this question
or