Not able to delete a row or a record from javascript

Hi,

Here is my grid:

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

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. 
 
[Index.cshtml] 
 
        <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> 
             
            <e-grid-columns> 
                . . . .  
            </e-grid-columns> 
        </ejs-grid> 
   
 
 
 
Refer the help documentation 
 
 
Regards, 
Thavasianand S. 


Loader.
Up arrow icon