Created
October 5, 2013 09:52
-
-
Save app2641/6838959 to your computer and use it in GitHub Desktop.
InfiniteGrid とFiltersFeature の併用バグの対策 ref: http://qiita.com/app2641/items/cc691ecd86c50932f488
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.override(Ext.data.Store, { | |
refetchPage: function(page, options, forceLoad) { | |
var me = this, | |
pageSize = me.pageSize || 200, | |
start = (page - 1) * me.pageSize, | |
end = start + pageSize; | |
if (me.getCount() === me.getTotalCount() && !forceLoad) { | |
return; | |
} | |
if (Ext.Array.indexOf(me.pagesRequests, page) === -1 && !me.rangeCached(start, end)) { | |
me.pagesRequests.push(page); | |
options = Ext.apply({ | |
page : page, | |
start : start, | |
limit : pageSize, | |
callback : me.onWaitForGuarantee, | |
scope : me | |
}, options); | |
me.prefetch(options); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.override(Ext.ux.grid.FiltersFeature, { | |
reload: function() { | |
var me = this, | |
grid = me.getGridPanel(), | |
filters = grid.filters.getFilterData(), | |
store = me.view.getStore(), | |
proxy = store.getProxy(); | |
// ストアのプリフェッチキャッシュを削除する | |
store.pagesRequests = []; | |
store.pageMap.map = {}; | |
store.pageMap.length = 0; | |
proxy.extraParams = me.buildQuery(filters); | |
// フィルタしたデータをサーバへリクエスト | |
store.prefetchPage(1, { | |
callback: function(records, operation, success) { | |
if (success) { | |
guaranteeRange = records.length < store.pageSize ? records.length : store.pageSize; | |
store.guaranteedStart = 0; | |
store.guaranteedEnd = 199; | |
store.loadRecords(Ext.Array.slice(records, 0, guaranteeRange)); | |
grid.getView().scrollBy(0, 0); | |
} | |
} | |
}, true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
store.pagesRequests = []; | |
store.pageMap.map = {}; | |
store.pageMap.length = 0; | |
proxy.extraParams = me.buildQuery(filters); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
callback: function(records, operation, success) { | |
if (success) { | |
guaranteeRange = records.length < store.pageSize ? records.length : store.pageSize; | |
store.guaranteedStart = 0; | |
store.guaranteedEnd = 199; | |
store.loadRecords(Ext.Array.slice(records, 0, guaranteeRange)); | |
grid.getView().scrollBy(0, 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment