Use RadConfirm in RibbonBar's client-side button clicking event?

3 posts, 1 answers
  1. JP
    JP avatar
    120 posts
    Member since:
    Aug 2011

    Posted 22 Nov 2013 Link to this post

    Hi,

    I want to show a RadConfirm when a certain ribbon bar button is clicked (in the client-side event handler), so the user can cancel the event.
    Because the RadConfirm uses a callback, I have to cancel the click event, show the RadConfirm, and in the callback I have to do a postback if the user clicked "yes".
    If found this example: http://demos.telerik.com/aspnet-ajax/window/examples/confirmserverclicks/defaultcs.aspx
    How can I use this approach for a RibbonBarButton?

    I have so far (pseudocode):
    function OnRibbonBarButtonClicking(sender, args) {
       if (args.get_button().get_value() == "delete") {
          args.set_cancel(true);
          radConfirm("Sure?", _callbackFunc);
       }
    }
     
    function _callbackFunc(arg) {
       if (arg) {
          // do postback, but how?
       }
    }

  2. Answer
    Bozhidar
    Admin
    Bozhidar avatar
    1101 posts

    Posted 27 Nov 2013 Link to this post

    Hello,

    Below is the modified code that implements your requirement:
    var eventArgs;
     
    function onClientButtonClicking(sender, args) {
        if (args.get_button().get_value() == "delete") {
                         
            // Cache the event arguments
            eventArgs = args;
     
            args.set_cancel(true);
            radconfirm("Sure?", _callbackFunc);
        }
    }
    function _callbackFunc(arg) {
        if (arg) {
                         
            var ribbonBar = $find("RadRibbonBar1");
                     
            // raise OnClientBUttonClicked event
            $telerik.$.raiseControlEvent(ribbonBar, "buttonClicked", eventArgs);
                                     
            // raise OnButtonClick server event
            ribbonBar.postback(eventArgs.get_button().get_hierarchicalIndex());
     
        }
    }


    Regards,
    Bozhidar
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. JP
    JP avatar
    120 posts
    Member since:
    Aug 2011

    Posted 02 Dec 2013 Link to this post

    Thanks, that's exactly what I was looking for!
Back to Top