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

Expand/Collapse problem after DataBind in AJAX method

5 Answers 117 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Alexey
Top achievements
Rank 1
Alexey asked on 02 Mar 2012, 09:38 AM
Hello all,

I have a problem with RadTreeList when use DataBind in AJAX method.
This is ASPX
<telerik:RadAjaxManager ID="AjaxManager" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btnSearch">
                    <UpdatedControls>                        <telerik:AjaxUpdatedControl ControlID="rtlSearchResult" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
<asp:Button ID="btnSearch" OnClick="btnSearchClick" runat="server" />
<telerik:RadTreeList runat="server" ID="rtlSearchResult" EnableNoRecordsTemplate="true"
 AllowPaging="false" PageSize="5" DataKeyNames="_ID" ParentDataKeyNames="_ID_FOLDER"
 Height="250" AllowLoadOnDemand="false" OnItemCommand="rtlSearchResult_ItemCommand"
 AutoGenerateColumns="false" Visible="true">
 <Columns>
    <telerik:TreeListBoundColumn DataField="_ID" UniqueName="_ID" HeaderText="ID"></telerik:TreeListBoundColumn>
    <telerik:TreeListBoundColumn DataField="_NAME" UniqueName="_NAME" HeaderText="NAME"></telerik:TreeListBoundColumn>
</Columns>
</telerik:RadTreeList>

CodeBehind

 

public List<common.DOCUMENT_OBJECT_MAP> list;
 
        protected void Page_Load(object sender, EventArgs e)
        {
            list = new List<common.DOCUMENT_OBJECT_MAP>();
 
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 1, NAME = "Obj1" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 11, ID_FOLDER = 1, NAME = "Obj11" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 12, ID_FOLDER = 1, NAME = "Obj12" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 13, ID_FOLDER = 1, NAME = "Obj13" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 14, ID_FOLDER = 13, NAME = "Obj14" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 15, ID_FOLDER = 13, NAME = "Obj15" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 16, ID_FOLDER = 14, NAME = "Obj16" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 17, ID_FOLDER = 14, NAME = "Obj17" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 18, ID_FOLDER = 14, NAME = "Obj18" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 2, NAME = "Obj2" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 3, NAME = "Obj33" });
 
            if (!IsPostBack)
            {
                rtlSearchResult.DataSource = list;
                rtlSearchResult.DataBind();
            }
}
protected void btnSearchClick(object sender, EventArgs e)
{
          rtlSearchResult.DataSource = list;
          rtlSearchResult.DataBind();
}
protected void rtlSearchResult_ItemCommand(object sender, TreeListCommandEventArgs e)
{
            if (e.CommandName == RadTreeList.ExpandCollapseCommandName)
            {
                rtlSearchResult.DataSource = list;
                rtlSearchResult.DataBind();
            }
}

When is no postback TreeList good work, exand and collapse nodes, but when I click to btnSearch I can't expand/collapse any node. Anybody could help me? Where is a bug?
Thanks!

Alexey

 

 

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Mar 2012, 10:29 AM
Hello,

I cannot reproduce the issue at my end. Make sure that you are using advanced data binding using NeedDataSource event to bind the treelist. Also check the following help documentation.
Simple vs Advanced Binding.

-Shinu.
0
Alexey
Top achievements
Rank 1
answered on 02 Mar 2012, 10:43 AM
I don't use OnNeedDataSource only simple binding to object list and

ItemCommand event for expand/collapse. I saw this example http://www.telerik.com/help/aspnet-ajax/treelist-simple-vs-advanced-binding.html 

0
Alexey
Top achievements
Rank 1
answered on 02 Mar 2012, 11:22 AM
I changed code to use NeedDataSource event, but problem is not solved.

ASPX
<telerik:RadScriptManager ID="ScriptManager" runat="server" EnableViewState="false"></telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="AjaxManager" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rtlSearchResult">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rtlSearchResult" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnSearch">
                    <UpdatedControls><telerik:AjaxUpdatedControl ControlID="rtlSearchResult" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                            </AjaxSettings>
            <ClientEvents OnResponseEnd="OnResponseEnd" />
        </telerik:RadAjaxManager>
<asp:Button ID="btnSearch" OnClick="btnSearchClick" runat="server" />
<telerik:RadTreeList runat="server" ID="rtlSearchResult" EnableNoRecordsTemplate="true"
                                AllowPaging="false" PageSize="5" DataKeyNames="_ID" ParentDataKeyNames="_ID_FOLDER"
                                Height="250" AllowLoadOnDemand="false" OnNeedDataSource="rtlSearchResult_NeedDataSource"
                                AutoGenerateColumns="false" Visible="true">
                                <Columns>
                                    <telerik:TreeListBoundColumn DataField="_ID" UniqueName="_ID" HeaderText="ID"></telerik:TreeListBoundColumn>
                                    <telerik:TreeListBoundColumn DataField="_NAME" UniqueName="_NAME" HeaderText="NAME"></telerik:TreeListBoundColumn>
                                </Columns>
</telerik:RadTreeList>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"/>

Codebehind
public List<common.DOCUMENT_OBJECT_MAP> list;
 
        protected void Page_Load(object sender, EventArgs e)
        {
            list = new List<common.DOCUMENT_OBJECT_MAP>();
 
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 1, NAME = "Obj1" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 11, ID_FOLDER = 1, NAME = "Obj11" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 12, ID_FOLDER = 1, NAME = "Obj12" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 13, ID_FOLDER = 1, NAME = "Obj13" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 14, ID_FOLDER = 13, NAME = "Obj14" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 15, ID_FOLDER = 13, NAME = "Obj15" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 16, ID_FOLDER = 14, NAME = "Obj16" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 17, ID_FOLDER = 14, NAME = "Obj17" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 18, ID_FOLDER = 14, NAME = "Obj18" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 2, NAME = "Obj2" });
            list.Add(new common.DOCUMENT_OBJECT_MAP() { ID = 3, NAME = "Obj3" });
 
}
protected void btnSearchClick(object sender, EventArgs e)
{
}
protected void rtlSearchResult_NeedDataSource(object sender, TreeListNeedDataSourceEventArgs e)
{
             
                rtlSearchResult.DataSource = list;
             
}

Problem the same I can expand/collapse before I click on btnSearch after it any node can not be expanded/collapsed and OnRespondEnd evend not fired on the client. Please help.

Thanks!

Alexey
0
Maria Ilieva
Telerik team
answered on 07 Mar 2012, 10:47 AM
Hello,

Please inspect the application and verify if any javascript error appear on your second try to expand a level after postback from the button. I would suggest you to see the following online demo which shows RadTreeList control with advanced databinding and you could initiate postback with the configurator checkbox which updates the TreeList exactly as it is in your application.
The presented demo works correctly on my side. Test it locally and verify what the difference in your case is.

Greetings,
Maria Ilieva
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
Alexey
Top achievements
Rank 1
answered on 07 Mar 2012, 11:47 AM
Thanks!
Tags
TreeList
Asked by
Alexey
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Alexey
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or