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

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

2 Answers 18 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
JP
Top achievements
Rank 1
JP asked on 22 Nov 2013, 04:32 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Bozhidar
Telerik team
answered on 27 Nov 2013, 09:05 AM
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.
0
JP
Top achievements
Rank 1
answered on 02 Dec 2013, 10:47 AM
Thanks, that's exactly what I was looking for!
Tags
RibbonBar
Asked by
JP
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
JP
Top achievements
Rank 1
Share this question
or