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

Targetting AJAX update from a RadTree

1 Answer 41 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 01 Mar 2011, 12:49 PM

Hello

I'm having a bit of a problem with an AJAX update from within a RadTree, I've had a look around the forums and can't find a proper answer to my prolem although I have stumbled across a couple of posts that given me a couple of ideas. Anyway, here is my problem, I hope someone can help.

What I'm effectivly trying to do is differentiate between clicking on a node in a RadTreeVew (to update the main panel) and dragging a node in a RadTreeView (to update a graph) during an AJAX update, unfortuately it seems that the EventName property of the RadAjaxManager AjaxSetting does not work as mentioned in this post (http://www.telerik.com/community/forums/aspnet-ajax/ajax/ajax-manager-event-filter.aspx)  reading on on this post Nicholas Walker (10th post) suggests a workaround in which you use the OnClientNodeClicked and OnClientNodeDropped properties of the RadTreeView to fire some JavaScript which modifies(?) the RadAjaxManager. I can get one or the other to work and I'm not really sure how the JavaScript fits in, ideally for one or the other, I want to disable the opposite manager update but I'm not sure how this could be done with javascript, or whether it could be done at all.
 

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
     <AjaxSettings>
         <telerik:AjaxSetting AjaxControlID="radTree" EventName="onTreeViewNodeDrop">
             <UpdatedControls>
                 <telerik:AjaxUpdatedControl ControlID="divWatchMeasureChart1" LoadingPanelID="RadAjaxLoadingPanel1" />
                 <telerik:AjaxUpdatedControl ControlID="lbMeasureName" />
             </UpdatedControls>
         </telerik:AjaxSetting>
         <telerik:AjaxSetting AjaxControlID="radTree" EventName="onTreeViewNodeClicked">
             <UpdatedControls>
                 <telerik:AjaxUpdatedControl ControlID="mainRight" LoadingPanelID="RadAjaxLoadingPanel1"/>
             </UpdatedControls>
         </telerik:AjaxSetting>
     </AjaxSettings>
</telerik:RadAjaxManager>
   
<div class="treeHolder">
  <telerik:RadTreeView ID="radTree" Runat="server" Skin="Windows7" 
     onclientnodedatabound="OnClientNodeDataBoundHandler" 
     onnodeclick="radTree_NodeClick" EnableDragAndDrop="True"
     OnNodeDrop="RadTreeView1_NodeDrop" OnClientNodeClicked="onTreeViewNodeClicked" OnClientNodeDropped="onTreeViewNodeDrop">
     <WebServiceSettings Path="~\Controls\WebController.aspx" Method="GetChildren" />
  </telerik:RadTreeView>
<div>
  
<telerik:RadScriptBlock runat="server">
<script language="javascript">
    function OnClientNodeDataBoundHandler(sender, e) {
        var node = e.get_node();
        node.set_toolTip(node.get_attributes().getAttribute("ToolTip"));
    }
  
    function onTreeViewNodeClicked(sender, eventArgs) 
    {
        var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
        if (ajaxManager != null) 
        {
            var settings = ajaxManager.get_ajaxSettings();
            for (setting in settings) 
            {
                var initiatingControl = settings[setting].InitControlID;
                var controls = settings[setting].UpdatedControls;
                if (initiatingControl == '<%= radTree.ClientID %>') {
  
                    for (control in controls) 
                    {
                        if (controls[control].ControlID != "mainRight")
                        {//disable all other updates perhaps?
                        }
                    }
                }
  
            }
  
            ajaxManager.set_ajaxSettings(settings);
        }
    }
  
  
    function onTreeViewNodeDrop(sender, eventArgs) 
    {
        var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
        if (ajaxManager != null) {
            var settings = ajaxManager.get_ajaxSettings();
            for (setting in settings) {
                var initiatingControl = settings[setting].InitControlID;
                var controls = settings[setting].UpdatedControls;
                if (initiatingControl == '<%= radTree.ClientID %>') {
                    for (control in controls) 
                    {
                        if (controls[control].ControlID != "CntrlViewOverview1_divWatchMeasureChart1") 
                        {//disable all other updates perhaps?
                        }
                    }
                }
  
            }
  
            ajaxManager.set_ajaxSettings(settings);
        }
    }
  
</script>
</telerik:RadScriptBlock>

This whole issue seems to be a bit of an oversight as it would seem sensible that you would want to react to a drag differently to a click, hopefully someone will have an answer to this and eny my multi-day efforts in getting this working. Thank you.

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 07 Mar 2011, 11:57 AM
Hello Andrew,

Indeed, you cannot use the EventName of the RadAjaxManager settings for your purpose. Furthermore, I can see in your specific scenario you are updating DIVs or Panels. But when a container control is set as updated control it behaves like being wrapped in ASP:UpdatePanel with UpdateMode set Always. Thus whatever controls on the page invokes ajax request, the container control content will be updated unconditionally.
Therefore in order to achieve your goal, I would suggest that you either use ASP:UpdatePanel controls to ajaxify the page content or RadAjaxPanels as in the attached demo.
Other than this, there are a few approaches one can follow to achieve conditional updates with RadAjaxManager, but they are applicable when the updated controls are not containers.

Regards,
Iana
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Ajax
Asked by
Andrew
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or