Я хочу добавить фильтр в свою сетку, которая выгружается локально.
Проблема, с которой я столкнулся, заключается в том, что эта реализация фильтрует только текущую страницу сетки, а не все данные хранилища, связанные с сеткой.
Есть ли обходной путь с использованием фильтра на прокси? или каким-либо образом заставить его фильтровать полные данные магазина.
Заранее спасибо.
Ниже представлена моя сетка:
Ext.define('MyApp.view.grid.FAQGrid', {
extend: 'Ext.grid.Panel',
xtype: 'faqQuesGrid',
store: 'faqQuestionsStore',
title: 'FAQ',
columnLines: true,
stripeRows: true,
columns: {
defaults:
{
resizable: false
},
items:
[{
header: 'Title',
dataIndex: 'title',
width: '77%'
},
{
header: 'Category',
dataIndex: 'categoriesName',
width: '10%',
renderer: function(value) {
return '<a href="#">' + value + '</a>';
}
},
{
header: 'Published Date',
dataIndex: 'publishedDate',
width: '11.5%'
}]
},
plugins: [{
ptype: 'rowexpander',
pluginId: 'faqRowId',
rowBodyTpl: new Ext.XTemplate (
'<p><b>Question: </b> {question}</p>',
'<p><br/><b>Answer: </b>',
'<tpl if="writtenAnswer">',
'{writtenAnswer}',
'</tpl>',
'<tpl if="videoAnswer">',
'{videoAnswer}',
'</tpl>',
'</p>',
'<p><br/><i><b>Posted on</b> {publishedDate} | <b>Filed Under</b>: {categoriesName}</i></p>',
'<tpl if="searchTagsName">',
'<p><i><b>Tags</b>: ',
'<tpl for="searchTagsName">',
'{.};',
'</tpl>',
'</i></p>',
'</tpl>'
)
}],
tools:
[{
xtype: 'button',
text: 'Expand All',
itemId: 'expandButtonId',
iconAlign: 'left',
style: 'margin: 5px'
},{
xtype: 'button',
text: 'Collapse All',
itemId: 'collapseButtonId',
iconAlign: 'left',
style: 'margin: 5px'
},{
xtype: 'textfield',
itemId: 'searchItem',
allowBlank: false,
emptyText: 'Search FAQ',
style: 'margin: 5px'
},{
baseCls: 'search-icon',
itemId: 'searchIconId',
height: 20,
iconAlign: 'right',
tooltip: 'Search Grid',
style: 'margin: 5px'
}],
dockedItems:
[{
xtype: 'pagingtoolbar',
dock: 'bottom',
store: 'faqQuestionsStore',
itemId: 'faqPagingToolbarId',
displayInfo: true,
displayMsg: 'Displaying questions {0} - {1} of {2}',
emptyMsg: "No questions to display",
}],
listeners: {
cellclick : function(grid, rowIndex, cellIndex, record, e) {
if(cellIndex == 2){
var clickedDataIndex = grid.headerCt.getGridColumns()[cellIndex].dataIndex;
var clickedCellValue = record.get(clickedDataIndex);
MyApp.app.getController('MyApp.controller.CategoriesController').getCategoryQuestions(clickedCellValue);
}
}
}
});
Магазин:
Ext.define('MyApp.store.FAQQuestionsStore', {
extend: 'Ext.data.Store',
model: 'MyApp.model.QuestionsModel',
requires: [
'MyApp.model.QuestionsModel'
],
storeId: 'faqQuestionsStore',
autoLoad: false,
remoteSort: true,
remoteFilter: false,
pageSize: 25,
proxy: {
type: 'memory',
enablePaging: true,
reader: {
type: 'json'
}
}
});
Я выполняю фильтрацию, как показано ниже:
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();
}
}
remoteFilter: true
. - person Evan Trimboli   schedule 27.10.2014