3 * @class Ext.ux.data.PagingMemoryProxy
4 * @extends Ext.data.proxy.Memory
5 * <p>Paging Memory Proxy, allows to use paging grid with in memory dataset</p>
7 Ext.define('Ext.ux.data.PagingMemoryProxy', {
8 extend: 'Ext.data.proxy.Memory',
9 alias: 'proxy.pagingmemory',
10 read : function(operation, callback, scope){
11 var reader = this.getReader(),
12 result = reader.read(this.data),
13 sorters, filters, sorterFn, records;
16 filters = operation.filters;
17 if (filters.length > 0) {
18 //at this point we have an array of Ext.util.Filter objects to filter with,
19 //so here we construct a function that combines these filters by ANDing them together
22 Ext.each(result.records, function(record) {
24 length = filters.length,
27 for (i = 0; i < length; i++) {
28 var filter = filters[i],
32 isMatch = isMatch && fn.call(scope, record);
39 result.records = records;
43 sorters = operation.sorters;
44 if (sorters.length > 0) {
45 //construct an amalgamated sorter function which combines all of the Sorters passed
46 sorterFn = function(r1, r2) {
47 var result = sorters[0].sort(r1, r2),
48 length = sorters.length,
51 //if we have more than one sorter, OR any additional sorter functions together
52 for (i = 1; i < length; i++) {
53 result = result || sorters[i].sort.call(this, r1, r2);
59 result.records.sort(sorterFn);
62 // paging (use undefined cause start can also be 0 (thus false))
63 if (operation.start !== undefined && operation.limit !== undefined) {
64 result.records = result.records.slice(operation.start, operation.start + operation.limit);
67 Ext.apply(operation, {
71 operation.setCompleted();
72 operation.setSuccessful();
74 Ext.callback(callback, scope || me, [operation]);
79 Ext.data.PagingMemoryProxy = Ext.ux.data.PagingMemoryProxy;