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
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

ejGrid allow insertion of only one record

Thread ID:





145364 Jun 18,2019 08:59 AM UTC Jun 21,2019 04:28 AM UTC jQuery 5
Tags: ejmGrid
Ali Ossaily
Asked On June 18, 2019 08:59 AM UTC

I want to disable the add button when the number of records is greater than zero

Thavasianand Sankaranarayanan [Syncfusion]
Replied On June 19, 2019 07:09 AM UTC

Hi Ali,  

Thanks for contacting Syncfusion support.  

Query: “I want to disable the add button when the number of records is greater than zero 

As per your requirement we have disabled the Add toolbar item using dataBound event and actionComplete event of Grid. Refer the below code example. 

let grid: Grid = new Grid( 
            dataSource: [], 
            editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal', newRowPosition: 'Top' }, 
            allowPaging: true, 
            dataBound: function(args){ 
              if(grid.getCurrentViewRecords().length > 0)// to disbale the add toolbar during intial rendering  
            actionComplete: function(args){ 
              if(args.requestType == "save"){// to disbale the toolbar when a record is added 
            pageSettings: { pageCount: 5 }, 

For your convenience we have prepared sample which can be referred below  

Refer our documentation for your reference 

Note: Please clarify whether you have using ej 1 Grid or ej 2 Grid in your application ?. In the above we have provided the solution for ej 2 Grid. 

Please get back to us if you have further queries.  

Thavasianand S.  

Ali Ossaily
Replied On June 19, 2019 07:15 AM UTC

Thanks for your support , kindly note that I'm using ej1 Grid

Manivannan Padmanaban [Syncfusion]
Replied On June 20, 2019 09:41 AM UTC

Hi Ali, 

Thanks for the details. 

As per your request, we have prepared the solution in EJ 1 Grid. Kindly refer the below code example, 

<script type="text/javascript"> 
    $(function () { 
            dataSource: window.gridData, 
            dataBound: function (args) { 
                if (this.model.currentViewData.length > 0) 
                    $("#Grid_add").addClass("e-disable") // Use your grid ID here. 
            allowPaging: true, 
            editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true }, 
            toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] }, 
            columns: [ 

Help documentation Link, 

Manivannan Padmanaban.  

Ali Ossaily
Replied On June 20, 2019 10:01 AM UTC

Thanks Alot , it works

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On June 21, 2019 04:28 AM UTC

Hi Ali,  

Thanks for your update. Please get back to us if you need any further assistance. 

Farveen sulthana T 


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