TreeView is not getting refreshed when I bind it from AjaxManager_AjaxReqest

4 posts, 1 answers
  1. Phani
    Phani avatar
    10 posts
    Member since:
    Mar 2015

    Posted 28 Jul 2015 Link to this post

    Dear Team,

    I'm displaying hierarchical data using Treeview. We need to change the datasource of treeview dynamically based on user input. I'm using the below code do achieve the functionality:

    In ASPX:

    function LoadTreeView(projectid) {
                            var ajaxManager = $find("<%= RadAjaxManagerforGrid.ClientID %>");
                            ajaxManager.ajaxRequest("treeview_databind," + projectid);
                         }

     

    In Code behind:

    protected void RadAjaxManagerforGrid_AjaxRequest(object sender, AjaxRequestEventArgs e)
           {
               string[] arguments = e.Argument.Split(',');
               if (arguments[0] == "search")
               {
                   string _search = arguments[1];
                   int result = BindProjectData(false, _search);
                   if (result == 0)
                   {
                       Label lblEmptyMessage = RadListView1.Controls[0].FindControl("lblmessage") as Label;
                       lblEmptyMessage.Text = "No records to display.";
                   }
               }
               else if(arguments[0] == "treeview_databind")
               {
                   int? folderId = Convert.ToInt32(arguments[1]);
                   BindFolderTreeViewData(folderId);
                   hdnSelectedFolderId.Value = arguments[1];
                   ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alertScript", "$('#video-move').modal('show');", true);
               }
           }

     

    BindFolderTreeViewData() Method:

     

    protected void BindFolderTreeViewData(int? folderId)
           {
               if(folderId!=null)
               {
               RadTreeFolders.Nodes.Clear();
               List<Folder> lst = DomainDAL.GetFolderHierarchy(folderId);
               RadTreeFolders.DataSource = lst;
               RadTreeFolders.DataFieldID = "FolderID";
               RadTreeFolders.DataFieldParentID = "ParentFolderID";
               RadTreeFolders.DataValueField = "FolderID";
               RadTreeFolders.DataTextField = "FolderName";
               RadTreeFolders.DataBind();
          }

     

    Treeview is not getting refreshed/not displaying any data. Can you please help

     

    Thanks,

    Phani

  2. Answer
    Eyup
    Admin
    Eyup avatar
    3013 posts

    Posted 31 Jul 2015 Link to this post

    Hello Phani,

    In order for the AjaxRequest event handler to have effect over other controls, they should be set as UpdatedControls by the manager in the AjaxSettings:
    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="RadTreeView1" />
        </UpdatedControls>
    </telerik:AjaxSetting>

    Could you verify that this is done on your side?

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Phani
    Phani avatar
    10 posts
    Member since:
    Mar 2015

    Posted 31 Jul 2015 in reply to Eyup Link to this post

    Thanks Eyup. I verified the Ajax Settings. I defined wrongly. That is the reason, it was not getting updated properly.

     

    Thanks for your help.

    Phani

  5. Eyup
    Admin
    Eyup avatar
    3013 posts

    Posted 03 Aug 2015 Link to this post

    Hello Phani,

    I'm glad the suggested solution has proven helpful.
    Please keep in mind that using RadAjaxPanel simultaneously with RadAjaxManager or UpdatePanel ( or implementing multiple wrapped RadAjaxPanels ) is not a supported scenario and we highly recommend to avoid such implementation. Either use just the manager to update your controls replacing the UpdatePanel / RadAjaxPanel with a regular asp:Panel, or use the UpdatePanel / RadAjaxPanel alone to wrap your page:
    http://www.telerik.com/help/aspnet-ajax/ajax-controls-in-ajaxpanel-and-ajaxsettings.html


    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top