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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Disable custom toolbar buttons and conext menu item if no element is selected

Thread ID:





144434 May 6,2019 02:58 PM UTC May 8,2019 10:59 AM UTC Vue 1
Tags: Data Grid
Asked On May 6, 2019 02:58 PM UTC

I have custom buttons in the datagrid toolbar and in the conext menu.

How can I disable them if no entry in the grid is selected? Normally i would do sth like: :disabled="_.isEmpty(this.selectedRows)", but since they are generated automatically I don't know how to do that.

gridContextMenuItems: [
text: 'Copy Url',
target: '.e-content',
id: 'copyurl'

toolbarOptions: [
text: 'Copy url',
id: 'copyurl'

Pavithra Subramaniyam [Syncfusion]
Replied On May 8, 2019 10:59 AM UTC

Thanks for contacting Syncfusion support. 
From your query we found that you want to enable and disable the Grid toolbar and contextMenu items based on the Grid row selection. So we suggest to use the Grid rowSelected and rowDeselected event to achieve this requirement. Please refer the following code snippet, 
rowSelected: function(args) { 
        if (this.$refs.grid.getSelectedRecords().length) { 
            this.$refs.grid.ej2Instances.toolbarModule.enableItems(["copyurl"], true);           this.$refs.grid.ej2Instances.contextMenuModule.contextMenu.enableItems(['Copy Url'], true); 
rowDeselected: function(args) { 
        if (!this.$refs.grid.getSelectedRecords().length) { 
            this.$refs.grid.ej2Instances.toolbarModule.enableItems(["copyurl"], false); 
            this.$refs.grid.ej2Instances.contextMenuModule.contextMenu.enableItems(['Copy Url'], false); 
In the above code, we have used enableItems method of the contextMenu and Toolbar controls to achieve this requirement. We have prepared the sample for your reference and you can find that sample from the below link, 
Pavithra S. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon