Expand/Collapse problem after DataBind in AJAX method

6 posts, 0 answers
  1. Alexey
    Alexey avatar
    5 posts
    Member since:
    Jun 2011

    Posted 02 Mar 2012 Link to this post

    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

     

     

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Mar 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alexey
    Alexey avatar
    5 posts
    Member since:
    Jun 2011

    Posted 02 Mar 2012 Link to this post

    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 

  5. Alexey
    Alexey avatar
    5 posts
    Member since:
    Jun 2011

    Posted 02 Mar 2012 Link to this post

    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
  6. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 07 Mar 2012 Link to this post

    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.
  7. Alexey
    Alexey avatar
    5 posts
    Member since:
    Jun 2011

    Posted 07 Mar 2012 Link to this post

    Thanks!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017