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

TreeView is not getting refreshed when I bind it from AjaxManager_AjaxReqest

3 Answers 50 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Phani
Top achievements
Rank 1
Phani asked on 28 Jul 2015, 12:59 PM

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

3 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 31 Jul 2015, 06:56 AM
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
0
Phani
Top achievements
Rank 1
answered on 31 Jul 2015, 08:58 AM

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

0
Eyup
Telerik team
answered on 03 Aug 2015, 07:22 AM
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
Tags
TreeView
Asked by
Phani
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Phani
Top achievements
Rank 1
Share this question
or