Ext.define('Fiddle.PagingStore', {
extend: 'Ext.data.Store',
alias : 'store.paging',
proxy: {
type : 'memory',
enablePaging: true
},
/**
* filterchange allows us to add the local filters and sorters to the pageLoad,
* when a filter on the store changes
* @param config
*/
constructor(config) {
const me = this;
me.callParent([config]);
me.on('filterchange', me.loadPage, me, { args: [1, null] });
},
/**
* updateSorters is the updaterFn for sorters.
* Everytime we get a new SorterCollection we want to listen to `endupdate`, because
* returning to the third state (ASC,DESC,null) does not fire any other event or triggers
* any other method.
*
* @param {Ext.util.SorterCollection} sorterCollection
*/
updateSorters(sorterCollection) {
const me = this;
sorterCollection.on('endupdate', me.loadPage, me, { args: [null, null] });
},
/**
* extend loadPage mainly to add the sorters and filters to the options
* This ensures a local page load with sorters and filters.
* @param {number} [page=store.currentPage]
* @param {object} [options={_filters,_sorters}]
*/
loadPage(page, options) {
const me = this;
page = page || me.currentPage;
options = options || {
_filters: me.getFilters().items,
_sorters: me.getSorters().items
};
me.callParent([page, options]);
}
})
3条答案
按热度按时间byqmnocz1#
大概是这样的:
使用以下示例数据:
oknwwptz2#
@Joe:您可能需要重写
Ext.grid.plugin.BaseExporter.extractRows
才能使用collection.getRange()
而不是collection.getAt(i)
dy2hfwbg3#
这只是对Arthur Rubens答案的补充。如果你不使用过滤器和排序器,他的答案会起作用。
如果要使用筛选器或排序器,则可能要使用此存储类型(
paging
):