extjs4extjs4.1extjs4.2

How to clear the grid in Extjs


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

Sample code:

    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 help in advance.


Solution

  • Make sure you are using:

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

    If you want to remove all items, do:

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

    But be careful! That will delete everything!