如何清除Extjs中的网格

Jav*_*ner 6 extjs4 extjs4.1 extjs4.2

我在Extjs中有一个GridStore,它可以存储带有两个网格列的记录.我在Grid中存在一条记录时遇到问题,如果我删除了它在服务器端成功删除的网格,但仍然存在于Grid中.

示例代码:

    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
    })
Run Code Online (Sandbox Code Playgroud)

提前感谢您的帮助.

Mik*_*ike 13

确保您使用:

grid.getStore().remove(record); //remove record from grid
grid.getStore().sync(); //sync with server
Run Code Online (Sandbox Code Playgroud)

如果要删除所有项目,请执行以下操作:

grid.getStore().removeAll();
grid.getStore().sync();
Run Code Online (Sandbox Code Playgroud)

不过要小心!这将删除一切!