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

Client side method support, no button .click() ?

1 Answer 71 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Fred Taylor
Top achievements
Rank 1
Fred Taylor asked on 19 Aug 2011, 02:56 PM
I'm migrating several radmenu functions into a radribbonbar.  I have a scenario where I use a radconfirm to intercept a menuclick.  It appears that the ribbonbar doesn't support the .click() method for the buttons.  I could use a javascript confirm, then a .set_cancel() method but I want to use the radconfim if possible.

sample scripts:

var btnclickCalledAfterRadconfirm = false;
var RRB_lastClickedItem = null;
 
function btn_confirmCallbackFunction(args) {
                alert('debug 1');
                if (args) {
                    btnclickCalledAfterRadconfirm = true;
                    alert('debug 2');
                    // this works if this was a radmenuitem object
                     RRB_lastClickedItem.click(); --
                    alert('debug 3');
                }
                else
                    btnclickCalledAfterRadconfirm = false;
 
                RRB_lastClickedItem = null;
            }
 
            function RRB_Btn_OnClientItemClickingHandler(sender, eventArgs) {
 
                if (!btnclickCalledAfterRadconfirm) {
                    RRB_lastClickedItem = eventArgs.get_button();
                    var myText = RRB_lastClickedItem.get_text();
                    //alert('debug: ' + myText);
                    if (myText == 'Clear All') {
                        eventArgs.set_cancel(true);
                        radconfirm("Clear all Alarms?", btn_confirmCallbackFunction);
                    }
                    if (myText == 'Delete All') {
                        eventArgs.set_cancel(true);
                        radconfirm("Delete all Alarms?", btn_confirmCallbackFunction);
                    }
                    if (myText == 'Acknowledge All') {
                        eventArgs.set_cancel(true);
                        radconfirm("Acknowledge all Alarms?", btn_confirmCallbackFunction);
                    }
                    if (myText == 'Clear') {
                        eventArgs.set_cancel(true);
                        radconfirm("Clear selected Alarms?", btn_confirmCallbackFunction);
                    }
                    if (myText == 'Delete') {
                        eventArgs.set_cancel(true);
                        radconfirm("Delete selected Alarms?", btn_confirmCallbackFunction);
                    }
 
                    if (myText == 'Refresh') {
                        //alert('refresh');
                        eventArgs.set_cancel(true);
                        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequestWithTarget('<%= lbHiddenRefresh.UniqueID %>', '');
                    }
                }
                btnclickCalledAfterRadconfirm = false;
 
            }

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 24 Aug 2011, 12:12 PM
Hello Fred,

Indeed currently we have not implemented such method for the RibbonBarButton. However, when you use the following code you can easily achieve the desired behaviour and postback when needed in the btn_confirmCallbackFunction. You could store the button as a global variable in from the RRB_Btn_OnClientItemClickingHandler function.
ribbonBar.postback(button.get_hierarchicalIndex());

This is so, because the Button's click method should do only one thing - postback the page if there is a server-side event attached. There is no other client-side logic wired up on the click events of buttons, except firing the client- and server- side events.

I hope this helps.

Best wishes,
Simon
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
RibbonBar
Asked by
Fred Taylor
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or