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

TreeList auto-collapsing expanded items almost immediately after page load

4 Answers 88 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Ilian
Top achievements
Rank 1
Ilian asked on 26 Jul 2017, 07:36 AM

Здравейте! Hi!

I am experiencing unusual behavior with a RadTreeList that's residing inside a user control (.ascx).

Note: The user control is programmatically/dynamically added on Page_Load from the parent page.

 

The RadTreeList definition inside the user control is as follows:

    <telerik:RadTreeList ID="RadTreeList1" runat="server"

        ParentDataKeyNames="ParentId" DataKeyNames="DataId" AllowPaging="false"
        AutoGenerateColumns="false" AllowSorting="false" ExpandCollapseMode="Client" AllowMultiItemSelection="true">

        <Columns>
            <telerik:TreeListBoundColumn DataField="FullName" UniqueName="FullName" HeaderText="FullName">
            </telerik:TreeListBoundColumn>
        </Columns>
    </telerik:RadTreeList>

 

In the code behind of the user control, I do this inside Page_Load():

           RadTreeList1.DataSource = lst; // lst is of type List<object> and is populated with valid data

           RadTreeList1.ExpandAllItems();

When the page containing this user control loads, one can see that the RadTreeList is rendered initially in a fully expanded state, but about half a second or less later, all the expanded nodes are auto-collapsed by the client-side.

The stack trace (snapped in the "middle" of toggling an expanded node back to a collapsed state) from Dev Tools in Chrome is:

toggleExpandCollapse (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager2_TSM&compress=1&_TSM_CombinedScri…:22075)
initialize (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager2_TSM&compress=1&_TSM_CombinedScri…:21971)
endUpdate (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager2_TSM&compress=1&_TSM_CombinedScri…:2664)
endCreateComponents (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager2_TSM&compress=1&_TSM_CombinedScri…:3406)
_raiseInit (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager2_TSM&compress=1&_TSM_CombinedScri…:3548)
initialize (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager2_TSM&compress=1&_TSM_CombinedScri…:3424)
b (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager2_TSM&compress=1&_TSM_CombinedScri…:3504)
a (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager2_TSM&compress=1&_TSM_CombinedScri…:3515)

 

If I change the ExpandCollapseMode of the RadTreeList to "Server" (from "Client"), the RadTreeList is rendered in expanded state, and the client side does not auto-collapse it (expected behavior).

The problem with "Server" expansion mode is that it causes a full page postback on every node expand/collapse icon click, which is highly undesirable in our situation.

 

Please advise on how to avoid the auto-collapse of a fully expanded RadTreeList while in "Client" ExpandCollapseMode.

 

Thank you!

 

Additional Info: Telerik.Web.UI version is 2016.2.607.45

 

4 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 22 Oct 2017, 10:13 AM

Hi,

I experience a simuliar behaviour with 2017.3.... Components.

Is this already solved?

Regards Peter

0
Eyup
Telerik team
answered on 25 Oct 2017, 11:34 AM
Hello Peter,

Generally, ff you want to expand all items by default, please use the built-in method of the RadTreeList:
protected void rtlOrderDetails_PreRender(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        RadTreeList treeList = sender as RadTreeList;
        treeList.ExpandAllItems();
    }
}

However, given that you are using the following load mode:
<telerik:RadTreeList ... ExpandCollapseMode="Client">
</telerik:RadTreeList>

You can use this approach instead to achieve this requirement:
function buttonClick() {
    var treelist = $find('<%= RadTreeList1.ClientID %>');
    var items = treelist.get_dataItems();
    for (var i = 0; i < items.length; i++) {
        items[i].set_clientExpanded(false);
        items[i].toggleExpandCollapse();
    }
}

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Kasim
Top achievements
Rank 2
answered on 10 Dec 2018, 08:46 AM

Hi Eyup,

The solution you provide does work for the first time. But on every Ajax call it is throwing as below:

[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index] System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) +72 Telerik.Web.UI.RadTreeList.LoadClientState(Dictionary`2 clientState) +4035 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +1008 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3159

0
Eyup
Telerik team
answered on 11 Dec 2018, 05:56 AM
Hello Kasim,

I've replied to your query in your formal support ticket on this matter. I suggest that we continue our technical conversation there.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TreeList
Asked by
Ilian
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Eyup
Telerik team
Kasim
Top achievements
Rank 2
Share this question
or