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

Expand/Collapse All?

6 Answers 230 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 29 Nov 2010, 06:07 AM
Hi,

Is there a way to programmatically expand/collapse all rows in the hierarchy? I don't care if it's server-side or client-side at this point.

I had the idea of getting the INPUT element for the ExpandCollapseButton of each row and calling the click() function. However, forcing the exansion of a row causes a postback, hence I could not get the all to expand at once.

Do you have any ideas?

6 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 29 Nov 2010, 08:24 AM
Hello Peter,

You can use the ExpandAllItems and CollapseAllItems methods that RadTreeList server-side API provides. For more information you can review the following help article:

Getting familiar with RadTreeList server-side API

I hope this helps.

Greetings,
Martin
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
mr_dummy
Top achievements
Rank 2
answered on 20 Jan 2011, 10:51 AM
hi, is there any way to expand all item that have the same attributes in all levers but don't affect any row that not having those attribute.
beause the treelist only binds items that currently visible, so i can't set expand for all rows in the table
0
Martin
Telerik team
answered on 25 Jan 2011, 05:33 PM
Hello Peter,

I am afraid that such a scenario is not possible. The problem would be to expand a child item that has the needed attribute while its parent item does not have it (and therefore is collapsed). Since the parent item is collapsed there is no way to expand the child one.

My suggestion is to review this help topic and pay special attention to the ExpandItemToLevel(TreeListDataItem,int level) and ExpandToLevel(int level) methods which may be helpful for your scenario. 

I hope this helps.

All the best,
Martin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
John
Top achievements
Rank 1
answered on 23 May 2012, 06:43 PM
I am trying to get a treelist to be initially expanded, but it is not working for me.

 I'm getting an error on the expandallitems() call. Apparently the method calls Databind which can't be called in NeedDataSource. Where can I put the call? Is there something I can do in the aspx page to expand the TreeList?

Here's what I've got. 

        <telerik:RadTreeList ID="rtl_SAPDLD" runat="server" 
        ParentDataKeyNames="ParentID" DataKeyNames="ID"
        DataNavigateUrlField="WebAddress" AutoGenerateColumns="false"
        Skin="Default" style="margin-left: 15px" Width="800px">
                <Columns>
                <telerik:TreeListHyperLinkColumn DataTextField="Title" DataNavigateUrlFields="WebAddress"
UniqueName="Title" Target="_blank" />
            </Columns>
    </telerik:RadTreeList>
 
 
    Private Sub rtl_SAProc_NeedDataSource(sender As Object, e As Telerik.Web.UI.TreeListNeedDataSourceEventArgs) Handles rtl_SAPDLD.NeedDataSource
        Dim SCMS As New SCMSdb
        Dim sp As New DataTable
 
        sp = SCMS.qrySAProcPDLDTree(lblMgmtSysID.Text.ToString)
        If sp.Rows.Count > 0 Then
            rtl_SAPDLD.DataSource = sp
            rtl_SAPDLD.ExpandAllItems()
            lblSAPDLD.Text = "The following Subject Areas, Procedures, Program Descriptions and Legacy documents are maintained by this Management System:"
            SAPDLD_PlaceHolder.Visible = True
        Else
            lblSAPDLD.Text = "This Management System maintains no Subject Areas, Procedures, Program Descriptions or Legacy documents. "
            SAPDLD_PlaceHolder.Visible = False
        End If
 
    End Sub
0
Martin
Telerik team
answered on 24 May 2012, 07:56 AM
Hello John,

Have you tried whether calling ExpandAllItems on the PreRender event works for your scenario?

Greetings,
Martin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
John
Top achievements
Rank 1
answered on 24 May 2012, 11:40 AM
I was finally able to get it to work by moving my code into Page_Load.

Thanks, Martin!
Tags
TreeList
Asked by
Peter
Top achievements
Rank 1
Answers by
Martin
Telerik team
mr_dummy
Top achievements
Rank 2
John
Top achievements
Rank 1
Share this question
or