Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs EXT JS 5带客户端分页的本地网格过滤_Extjs_Pagination_Grid_Filtering_Extjs5 - Fatal编程技术网

Extjs EXT JS 5带客户端分页的本地网格过滤

Extjs EXT JS 5带客户端分页的本地网格过滤,extjs,pagination,grid,filtering,extjs5,Extjs,Pagination,Grid,Filtering,Extjs5,我想将过滤器添加到本地分页的网格中 我面临的问题是,这个实现只过滤网格的当前页面,而不是与网格关联的整个存储数据 在代理服务器上使用过滤器是否有解决方法?或者以任何方式使其对完整的存储数据进行过滤 提前谢谢 下面是我的表格: 我正在执行以下过滤: this.control({ 'faqQuesGrid #searchItem':{ change: this.filterQuestions } }); filter

我想将过滤器添加到本地分页的网格中

我面临的问题是,这个实现只过滤网格的当前页面,而不是与网格关联的整个存储数据

在代理服务器上使用过滤器是否有解决方法?或者以任何方式使其对完整的存储数据进行过滤

提前谢谢

下面是我的表格:

我正在执行以下过滤:

this.control({
            'faqQuesGrid #searchItem':{
                change: this.filterQuestions
            }
}); 

filterQuestions: function(textfield) {
        var grid = textfield.up('panel');
        var store = grid.getStore();
        if(store != null) {
            //clear filters first
            store.remoteFilter = false;
            store.clearFilter(true);

            var filters = new Array();

            //add filter to filter array
            if(textfield.isValid()){
                var searchTxt = textfield.getValue();

                //create filter and add to filters array
                var questionFilter = {
                    property: 'question',
                    anyMatch: true,
                    caseSensitive: false,
                    value   : searchTxt
                };

                filters.push(questionFilter);
            } else{
                 store.read();
            } 
            //else condition is necessary to populate the grid correctly when a search query is removed

            //add filters to store
            if(filters.length > 0){
                store.addFilter(filters);
            }
        }
    },

//to remove any filters added when we leave this page to prevent issues with other page functionality
deactivate: function(){
                    var store = Ext.getStore('faqQuesStore');
                    if(store != null){
                        store.clearFilter();
                    }

                }

正如Evan Trimboli在对您的问题的评论中提到的,您必须为store设置remoteFilter:true,以便使用内存代理过滤整个数据集


筛选正在代理服务器中远程进行。它就像一个服务器。本地过滤意味着在商店中进行过滤。远程意味着由代理处理它

我要注意的是,用于基于传递的Ext.util.filter[]创建具有属性值configs的筛选函数:

// Filter the resulting array of records 
if (filters && filters.length) {
    // Total will be updated by setting records 
    resultSet.setRecords(records = Ext.Array.filter(records, Ext.util.Filter.createFilterFn(filters)));
    resultSet.setTotal(records.length);
}

所以,若要使用不同的过滤逻辑,可以重写memroy代理读取方法,并使用自定义函数创建过滤函数。检查示例。

您需要设置remoteFilter:true。嗨,Evan,谢谢您的解决方案。将remoteFilter设置为true时,可以执行本地分页和筛选。但是,正如我从API文档中了解到的,对于服务器端操作,此配置设置为true。你能简要解释一下吗?感谢代理中正在远程进行筛选。它就像一个服务器。本地过滤意味着在商店中进行过滤。远程意味着由代理来处理。好的。这就是原因。@Evan-我将Sencha从5.0.0更新为5.1.3,但此解决方案不起作用。当remoteFilter:为true时,我无法将本地筛选器应用于我的存储。。
this.control({
            'faqQuesGrid #searchItem':{
                change: this.filterQuestions
            }
}); 

filterQuestions: function(textfield) {
        var grid = textfield.up('panel');
        var store = grid.getStore();
        if(store != null) {
            //clear filters first
            store.remoteFilter = false;
            store.clearFilter(true);

            var filters = new Array();

            //add filter to filter array
            if(textfield.isValid()){
                var searchTxt = textfield.getValue();

                //create filter and add to filters array
                var questionFilter = {
                    property: 'question',
                    anyMatch: true,
                    caseSensitive: false,
                    value   : searchTxt
                };

                filters.push(questionFilter);
            } else{
                 store.read();
            } 
            //else condition is necessary to populate the grid correctly when a search query is removed

            //add filters to store
            if(filters.length > 0){
                store.addFilter(filters);
            }
        }
    },

//to remove any filters added when we leave this page to prevent issues with other page functionality
deactivate: function(){
                    var store = Ext.getStore('faqQuesStore');
                    if(store != null){
                        store.clearFilter();
                    }

                }
// Filter the resulting array of records 
if (filters && filters.length) {
    // Total will be updated by setting records 
    resultSet.setRecords(records = Ext.Array.filter(records, Ext.util.Filter.createFilterFn(filters)));
    resultSet.setTotal(records.length);
}