如何重新加载原始存储网格在实时搜索一旦我的搜索文本字段是空的



我已经使用Extjs做了应用程序。我正在向用户显示网格记录,这里添加了livesearch的功能。通过在搜索字段的字段中输入一些文本,可以很好地根据属性名称和值进行过滤。但问题是,一旦我从搜索字段中删除文本时,搜索字段变成空/空白,时间原始存储数据不填充在网格中。我如何填充原始存储数据网格一旦搜索文本字段变为空?

升值。

我的代码在这里: incode newValue是搜索文本字段值,我正在检查是否有其他部分。如果newValue null表示需要加载原始存储,否则它将过滤存储并显示记录。我已经添加了下面的代码来重新加载原始存储不工作。

{
    xtype: 'textfield',
    name: 'searchField',
    hideLabel: true,
    width: 200,
    listeners: {
        change: {
            fn: this.onTextFieldChange,
            scope: this,
            buffer: 100
        }
    }
},
onTextFieldChange: function (field, newValue, oldValue, options) {
    if (newValue == '') {
        //grid.setStore(store);
        Ext.getCmp('grid').getStore().load();
        here grid is id of my Grid
        Ext.getCmp('grid').getView().refresh();
    } else {
        grid.store.load().filter([{
            id: 'name',
            property: "name",
            value: newValue,
            anyMatch: true
        }]);
    }
}

我已经添加了grid.store.clearFilter();一旦搜索文本字段为空,清除过滤器。工作很好。欢呼:)

最新更新