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

Not able to delete a row or a record from javascript


Here is my grid:

<ejs-grid id="aaGrid" allowPaging="true" allowSorting="true" queryCellInfo="CommonGridCellTemplate">
        <e-grid-column field="Id" isIdentity="true" isPrimaryKey="true" allowSorting="false" allowFiltering="false" visible="false"></e-grid-column>

Script code:
 var grid = document.getElementById("aaGrid").ej2_instances[0];
                grid.deleteRecord("Id", grid.getSelectedRecords()[0]);

ERROR when script gets executed: 
TypeError: Cannot read property 'deleteRecord' of undefined  at t.deleteRecord

1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team July 25, 2019 09:39 AM UTC

Hi John, 
Greetings from Syncfusion support. 
Query : Script error throws 
We have checked your query and in you may missed to include the editSettings model which is essential to perform add/edit/delete actions. So, we suggest you to include the editSettings model in Grid rendering code and you can delete the records in grid.  
Please refer the below example code. 
        <ejs-grid id="field-add-synonyms-list" dataSource=@ViewBag.dataSource allowfiltering="true" allowselection="true" rowselected="rowselected"> 
            <e-grid-filtersettings type="Menu"></e-grid-filtersettings> 
            <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings> 
                . . . .  
Refer the help documentation 
Thavasianand S. 

Live Chat Icon For mobile
Up arrow icon