Ajaxified radtreeview with radconfirm

2 posts, 0 answers
  1. Ratish Aravind
    Ratish Aravind avatar
    1 posts
    Member since:
    Sep 2009

    Posted 03 Dec 2010 Link to this post

    Hi,

    I have an ajaxified RadTreeView control. The treeview lists a database key field. Each node click populates the right hand side form based on the tree node value. I have used a AjaxLoadingPanel to give a rich user experience saying that the forms are getting loaded. Now I have a typically scenario when some form values gets changed and if the user clicks on another rad tree node I want to alert the user saying that "Data Has Been Changed. Do you want to save?". I have gone through the radconfirm forums and I managed to show the confirm box. Now I made some changes to the form and now I click on another node what is happening is the code i wrote on node click is executing and the form gets loaded based on the new rad tree node value and at last the radconfrim window opens up. I want the radconfirm to open even before the form gets processed based on the current node value. Also I have created a link button to do postback based on the radconfirm clicked value. It also works fine. But the main problem is the form gets processed with the current clicked node and then the radconfirm box opens up. I don't know if the RadAjaxmanager is causing some problem. I have attached the code for reference. Anyone who can help me with this will be highly appreciated.
    Also I have seen the kb articles for radtreeview but I don't know if that suits my scenario.
    function confirmCallBackFn(arg) {
      
    if (arg == true) {
      
    __doPostBack("<%= DummyButton.ClientID %>", "");
      
    }
      
    if (arg == false) {
      
    return; 
      
    }
      
    }
      
    <telerik:RadAjaxManager ID="AppRadAjaxManager" runat="server">
      
    <AjaxSettings>
      
      
          
    <telerik:AjaxSetting AjaxControlID="SearchTreeView" EventName="NodeClick">
      
    <UpdatedControls>
      
    <telerik:AjaxUpdatedControl ControlID="DetailFormPanel" LoadingPanelID="DetailsAjaxLoadingPanel" UpdatePanelRenderMode="Inline" />
      
    <telerik:AjaxUpdatedControl ControlID="Icto_No" UpdatePanelRenderMode="Inline" />
      
    <telerik:AjaxUpdatedControl ControlID="AppVerID" UpdatePanelRenderMode="Inline" />
      
    </UpdatedControls>
      
    </telerik:AjaxSetting>
      
      
    </AjaxSettings>
      
    <ClientEvents OnRequestStart="RequestStart" OnResponseEnd="ResponseEnd" />
      
    </telerik:RadAjaxManager>
      
    <telerik:RadAjaxLoadingPanel ID="DetailsAjaxLoadingPanel" Skin="Vista" runat="server">
      
    </telerik:RadAjaxLoadingPanel>

     

     

     

    This is the dummy control defintion for doing postback on radconfirm values:

     

    <asp:LinkButton ID="DummyButton" CausesValidation="false" Text="" Width="0" runat="server" />
    Code Behind:

    If

     

    DoDataCompare() Then AppRadAjaxManager.ResponseScripts.Add("radconfirm('Are you sure you want to navigate to a different node without saving your data?', confirmCallBackFn,330,100,null,'Save Changes?');")

     

     


    DoDataCompare will compare and return if there is a change occured in the form. If yes then only i want to show the radconfirm popup.I'm doing some processing after the above code block. So the problem is radconfirm popup doesn't popup at this time and only pop's up after the other code i have written under it. I have also tried the radconfirm block current code execution and it doesn't help either. This is my radwindow manager and block current code definitions:

    <telerik:RadWindowManager ShowContentDuringLoad="false" ID="RadWindowManager" Behaviors="Close, Move, Pin" ReloadOnShow="true" VisibleStatusbar="false" runat="server">
      
    <Windows>
      
    <telerik:RadWindow ID="RadWindow" Modal="true" Behaviors="Close, Move, Pin" Width="925px" Height="700px" runat="server"></telerik:RadWindow>
      
    </Windows>
      
    </telerik:RadWindowManager>
      
    <script type="text/javascript">
      
    //MAKE SURE THAT THE FOLLOWING SCRIPT IS PLACED AFTER THE RADWINDOWMANAGER DECLARATION
      
    //Replace old radconfirm with a changed version. 
      
    var oldConfirm = radconfirm;
      
    //TELERIK
      
    //window.radconfirm = function(text, mozEvent)
      
    //We will change the radconfirm function so it takes all the original radconfirm attributes
      
    window.radconfirm = function(text, mozEvent, oWidth, oHeight, callerObj, oTitle) {
      
    var ev = mozEvent ? mozEvent : window.event; //Moz support requires passing the event argument manually 
      
    //Cancel the event 
      
    ev.cancelBubble = true;
      
    ev.returnValue = false;
      
    if (ev.stopPropagation) ev.stopPropagation();
      
    if (ev.preventDefault) ev.preventDefault();
      
    //Determine who is the caller 
      
    var callerObj = ev.srcElement ? ev.srcElement : ev.target;
      
    //Call the original radconfirm and pass it all necessary parameters 
      
    if (callerObj) {
      
    //Show the confirm, then when it is closing, if returned value was true, automatically call the caller's click method again. 
      
    var callBackFn = function(arg) {
      
    if (arg) {
      
    callerObj["onclick"] = "";
      
    if (callerObj.click) callerObj.click(); //Works fine every time in IE, but does not work for links in Moz 
      
    else if (callerObj.tagName == "A") //We assume it is a link button! 
      
    {
      
    try {
      
    eval(callerObj.href)
      
    }
      
    catch (e) { }
      
    }
      
    }
      
    }
      
    //TELERIK
      
    //oldConfirm(text, callBackFn, 300, 100, null, null); 
      
    //We will need to modify the oldconfirm as well 
      
    oldConfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);
      
    }
      
    return false;
      
      
    </script>
    I have placed the block execution code after radwindowmanager as per the kb article but in that case the radconfirm doesn't popup. If i remove then it pops up. Also here is the code for the dummy control that does a postback:

     

    Protected

     

    Sub DummyButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DummyButton.Click

     

     

     

    End Sub

     

     

    I know I have wriiten a big story but i want to explain to the fullest so that whoever lokks at this won't get confused. Can anyone help me with why the code after radconfirm gets executed? I want the code to get executed only when the user clicks CANCEL and the code in the postback when the user clicks OK. 
    Thanks & Regards,
    Ratish

  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 09 Dec 2010 Link to this post

    Hello Ratish Aravind,

    Unfortunately i couldn't reproduce your problem since the code you've provided is insufficient. That's why i'm sending you an example project showing how to use treeview with radcomfirm. If you continue to experience your problem please send me a runnable version of your project.


    Best wishes,
    Dimitar Terziev
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top