RadConfirm on RadtreeView NodeClick

5 posts, 0 answers
  1. Courouble Damien
    Courouble Damien avatar
    54 posts
    Member since:
    Aug 2009

    Posted 27 Aug 2009 Link to this post

    Hi everybody !

    As you can see in my post title I try to find a way to have a radconfirm (client side) when the user is selecting (clicking) a node of a radtreeview.

    E.G > User is currently on a node called "Employee Example" on right panel I display some informations of the node using a query in database like name, surname ...of the employee the user can edit this and save by clicking a button save, but in case of the user change selecting node and don't push the save button I want to display a radconfirm saying " you've made some changes but you don't save if you continue all changes will be lost" and so the user will have choice to hit "Cancel" (so the right pane don't change) and if he hit "Ok"  then postback the right panel and display informations for the new selecting node.using query.

    For the moment I use the standard confirm, i also store a value in a hiddenfield, the value of it change by clicking on "Ok" or on "Cancel" and after in code behind I check the value to see if it's need to do the query, or not depending of the user choice, but of course it do posback in any cases that's what I want to change !

    I hope you'll understand my issue.

    Thanks in advance for reading this

    Regards,

    Damien



  2. Mr. Plinko
    Mr. Plinko avatar
    56 posts
    Member since:
    Jul 2009

    Posted 31 Aug 2009 Link to this post


    You can do throw an alert window when a user clicks on a node by using some Javascript and attaching it to a Client-Side event (eg OnClientNodeClicking)

    <body> 
        <form id="form1" runat="server"
        <telerik:RadScriptManager ID="RadScriptManager1"  
            runat="server"
        </telerik:RadScriptManager> 
     
        <telerik:RadTreeView ID="RadTreeView1"  
            Runat="server" OnClientNodeClicked="OnClientNodeClicked"
            <Nodes> 
                <telerik:RadTreeNode runat="server"  
                    Text="Root RadTreeNode1"
                </telerik:RadTreeNode> 
            </Nodes> 
        </telerik:RadTreeView> 
    <script language="javascript"
     
     
        function OnClientNodeClicked() 
        var agree = confirm("you've made some changes but you don't save if you continue all changes will be lost"); 
    if (agree) 
        return true ; 
    else 
        return false ; 
    </script> 
     
        </form> 
    </body> 

    Is that what you were asking?

  3. Courouble Damien
    Courouble Damien avatar
    54 posts
    Member since:
    Aug 2009

    Posted 01 Sep 2009 Link to this post

    Yes, that's approximatly it ! I mean I would be great if I can use a Radconfirm component instead of alert, is it possible ?
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 01 Sep 2009 Link to this post

    Hello Courouble Damien,

    Please find attached a sample project.

    All the best,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Courouble Damien
    Courouble Damien avatar
    54 posts
    Member since:
    Aug 2009

    Posted 02 Sep 2009 Link to this post

    Hi !!

    I've test your project on mine : that's work perfectly, many thanks !
    But there's one thing more I want to do : I want to add others parameters to the onclientnodeclicking for radconfirm text, title, width and height to be able to translate the confirm message.

    I use this function

    window.blockConfirm = 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) { }
                    }
                }
            }
            if (window.parent == null) {
                radconfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);
            }
            else {
                window.parent.radconfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);
            }
        }
        return false;
    }

    on my project so i'm able to declare this on in onclientclicking event in behind code and give this functions some c# vars.
    this one don't work on radmenu item clicking so I want to use the same way with your function : is it possible ?

    Thanks for helping me !

    Damien

Back to Top