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

Add an ID on a ButtonSettings inside the ribbon

Hi,
I have to add an ID, as how asp button works like: <asp:Button ID="aspButtonID"/> on all button inside my ribbon to check what button is clicked to do an javascript action. Like <ButtonSettings ID="ribbonButtonID"/>
I use the ribbon and the control on the assemblies

<%@ Register Assembly="Syncfusion.EJ.Web, Version=12.4450.0.24, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" Namespace="Syncfusion.JavaScript.Web" TagPrefix="ej" %>
<%@ Register Assembly="Syncfusion.EJ, Version=12.4450.0.24, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" Namespace="Syncfusion.JavaScript.Models" TagPrefix="ej" %>

Can you help me how to have an unique identifier for all button inside the ribbon?
Thanks a lot

7 Replies

SK Sarath Kumar P Syncfusion Team May 12, 2015 12:36 PM UTC

Hi Rakotondrabesa,

Thanks for using Syncfusion products.

We suggest you to provide unique ID for all buttons in the ribbon control use “ContentGroup” tag. Please refer the below Code snippets,

<ej:ContentGroup Id="cut" ToolTip="Cut" Text="Cut">

<ButtonSettings ContentType="TextAndImage" Type="Button" PrefixIcon="e-ribbon e-ribboncut" Click="executeAction" />

</ej:ContentGroup>

<ej:ContentGroup Id="copy" ToolTip="Copy" Text="Copy">

<ButtonSettings ContentType="TextAndImage" Type="Button" PrefixIcon="e-ribbon e-ribboncopy" Click="executeAction" />

</ej:ContentGroup>

<ej:ContentGroup Id="clear" ToolTip="Clear All " Text="Clear">

<ButtonSettings ContentType="TextAndImage" Type="Button" PrefixIcon="e-ribbon clearAll" Click="executeAction" />

</ej:ContentGroup>

To check which button is clicked during an javascript action use text of the button from the event’s arguments.

function executeAction(args) { // In the attached sample we have used common name for all button click events

var val=args.model.text; // Text of the button from the args.

}

Please find the below sample for your reference.

Sample: http://www.syncfusion.com/downloads/support/forum/119108/RibbonButton's_ID-384901057.zip

Please let us know if you need any further assistance.

Regards,

Sarath Kumar P.




RA Rakotondrabesa May 12, 2015 01:39 PM UTC

Hi,
I cannot use args.model.text because our web site is translated into several languages. So when I click on the button ButtonSettings with the attribute Click="executeAction" ,how can I work with the client event function executeAction(args) to know which is clicked?


SK Sarath Kumar P Syncfusion Team May 13, 2015 12:54 PM UTC

Hi Rakotondrabesa,

Thanks for your update.

We suggest you to use individual click event for each button and with this if your requirement is not resolved, please get back to us and we will analyze and update you the response accordingly.

Please let us know if you need any further assistance.

Regards,

Sarath Kumar P.



RA Rakotondrabesa May 13, 2015 02:48 PM UTC

Hi,
I know that it will be work if I use an individual click event for each button ,but I just think that it's a pity if I have to work with many events. Because I would create an Javascript dictionnary to associate the button ID clicked and the action to perform with the button. So I would work just with one event.
Thanks for your help ;) 


SK Sarath Kumar P Syncfusion Team May 14, 2015 10:07 AM UTC

Hi Rakotondrabesa,

Thanks for your update.

We suggest you to use “this._id” to achieve your requirement.Please refer the below Code snippets,

function executeAction(args) {

var val=this._id; //Use this._id to get clicked button’s id.

alert(val + " is clicked");

}

The ID format for ribbon button is Ribbon ID+”_”+Button ID. In the attached sample id of ribbon button “new” will be “defaultRibbon_new”.

Please find the below sample for your reference.

Sample: http://www.syncfusion.com/downloads/support/forum/119108/RibbonButton_id-1860333619.zip

Please let us know if you need any further assistance.

Regards,

Sarath Kumar P.



RA Rakotondrabesa May 18, 2015 07:34 AM UTC

Hi,
Thanks for this help,
I can get  ID with this._id;
regards


SK Sarath Kumar P Syncfusion Team May 19, 2015 03:54 AM UTC

Hi Rakotondrabesa,

Thanks for your update.

Please let us know if you need any assistance.

Regards,

Sarath Kumar P.


Loader.
Live Chat Icon For mobile
Up arrow icon