We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Ribbon click events

Trying to catch all click events in ribbon items

groupClick fires but I am at a loss on how to find out which button id was clicked by the user

thanks for any pointers

Mike

3 Replies

RK Rajesh Kumar Anburajan Syncfusion Team November 4, 2016 06:51 AM UTC

Hi Michael,   
    
Thanks for contacting Syncfusion support.   
  
Query: “how to find out which button id was clicked by the user”.   
   
You can get the clicked button id in the group click event using target element. Please refer to the following code example.   
   
groupClick: "groupClick"// initialize the groupclick event   
   
function groupClick(sender) { // define the groupclick event   
              //Here you can get the clicked button id   
                var btnId,target=$(sender.target);    
                var rbnButton= target.parents('.e-ribbonbtn')   
                if (target.hasClass('e-ribbonbtn'))   
                    btnId = target.attr('id');   
                else if (rbnButton.length > 0)   
                    btnId = rbnButton.attr('id');   
        }   
  
   
Please refer to the attached sample,   
  
Sample:   
  
Regards,   
Rajesh kumar A.   
 



MS Michael Salzlechner November 7, 2016 10:00 PM UTC

thanks

but this does not give me the id for the button added to the ribbon but rather a html id that combines the html id of the control plus the id of the button


RK Rajesh Kumar Anburajan Syncfusion Team November 8, 2016 10:31 AM UTC

Hi Michael,   
    
Thanks for your update,   
  
Query: “Id for the button added to the ribbon”.   
   
By default, Ribbon button controls id are standardized with “controlId_buttontext”. So element id will be created based on this structure in HTML.   
   
     
   
If you need to get only button text, then you can split the text from the target element id as shown below.   
   
btnText=btnId.slice(this._id.length+1);//Here this._id means ribbon control id   
   
   
Regards,   
Rajesh kumar A.   


Loader.
Up arrow icon