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

How to disable a specific button of a grid

Thread ID:

Created:

Updated:

Platform:

Replies:

117334 Sep 29,2014 06:25 PM Sep 30,2014 05:08 AM ASP.NET Web Forms 1
loading
Tags: Grid
Roimer Machacón Otero
Asked On September 29, 2014 06:25 PM

Hi we are using the grid control with the toolbar.

When we've the grid without rows need disable the delete button in the toolbar, exist some form to make this?

Please a example in code behind and javascript to compare which is the best way for our application

Ragavee U S [Syncfusion]
Replied On September 30, 2014 05:08 AM

Hi Nestor Alvarado Namen

 

Based on your requirement to disable the toolbar icon when the grid is empty, we have created a sample and the same can be downloaded from the below location.

 

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/Sample935536257.zip

 

In the above sample, we have disabled the delete icon in the actionComplete event of the grid when the grid has no records. Please refer the below code snippet.

 

<ej:Grid ID="OrdersGrid" runat="server" ActionComplete="onComplete">

. . .

ej:Grid>

<script type="text/javascript">

       function onComplete(args) {          

           if ($.isEmptyObject(args.model.currentViewData)) {

               var toolbarObj = $(".e-gridtoolbar").data("ejToolbar");

               toolbarObj.disableItem(".e-deleteitem");

           }

           else {

               var toolbarObj = $(".e-gridtoolbar").data("ejToolbar");

               toolbarObj.enableItem(".e-deleteitem");

           }

       }     

   script>

 

Also, we suggest you to use javascript in order to achieve your requirement as it will be more optimizable than to achieve using code-behind.

 

Please try the above sample and get back to us if you need any further assistance.

 

Regards

Ragavee U S

CONFIRMATION

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.

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.

;