How to clear grid in Extjs

I have a GridStore in Extjs that can store records with two grid columns. I have a problem when one record exists in the Grid, if I delete the grid, it was deleted successfully on the server side, but it still exists in the Grid.

Code example:

xtype: 'grid', store: 'SampleStore', border: false, width : 542, ref: '../sampleGrid', id: 'sampleGrid', columns: [ { xtype: 'gridcolumn', dataIndex: 'name', header: 'Name', sortable: true, ............. view: new Ext.grid.GridView({ forceFit: true }) 

Thanks for the help in advance.

+6
source share
2 answers

Make sure you use:

 grid.getStore().remove(record); //remove record from grid grid.getStore().sync(); //sync with server 

If you want to delete all items, follow these steps:

 grid.getStore().removeAll(); grid.getStore().sync(); 

But be careful! This will delete everything!

+9
source

This worked for me:

 Ext.ComponentQuery.query('#yourGrid')[0].getStore().removeAll(); 

Hope this helps.

0
source

Source: https://habr.com/ru/post/950176/


All Articles