3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">
9 /* Fix for Opera, which does not seem to include the map function on Array's */
10 if (!Array.prototype.map) {
11 Array.prototype.map = function(fun){
12 var len = this.length;
13 if (typeof fun != 'function') {
14 throw new TypeError();
16 var res = new Array(len);
17 var thisp = arguments[1];
18 for (var i = 0; i < len; i++) {
20 res[i] = fun.call(thisp, this[i], i, this);
27 Ext.ns('Ext.ux.data');
29 <div id="cls-Ext.ux.data.PagingMemoryProxy"></div>/**
30 * @class Ext.ux.data.PagingMemoryProxy
31 * @extends Ext.data.MemoryProxy
32 * <p>Paging Memory Proxy, allows to use paging grid with in memory dataset</p>
34 Ext.ux.data.PagingMemoryProxy = Ext.extend(Ext.data.MemoryProxy, {
35 constructor : function(data){
36 Ext.ux.data.PagingMemoryProxy.superclass.constructor.call(this);
39 doRequest : function(action, rs, params, reader, callback, scope, options){
44 result = reader.readRecords(this.data);
47 this.fireEvent('loadexception', this, options, null, e);
48 callback.call(scope, null, options, false);
53 if (params.filter !== undefined) {
54 result.records = result.records.filter(function(el){
55 if (typeof(el) == 'object') {
56 var att = params.filterCol || 0;
57 return String(el.data[att]).match(params.filter) ? true : false;
60 return String(el).match(params.filter) ? true : false;
63 result.totalRecords = result.records.length;
67 if (params.sort !== undefined) {
68 // use integer as params.sort to specify column, since arrays are not named
69 // params.sort=0; would also match a array without columns
70 var dir = String(params.dir).toUpperCase() == 'DESC' ? -1 : 1;
71 var fn = function(r1, r2){
74 result.records.sort(function(a, b){
76 if (typeof(a) == 'object') {
77 v = fn(a.data[params.sort], b.data[params.sort]) * dir;
83 v = (a.index < b.index ? -1 : 1);
88 // paging (use undefined cause start can also be 0 (thus false))
89 if (params.start !== undefined && params.limit !== undefined) {
90 result.records = result.records.slice(params.start, params.start + params.limit);
92 callback.call(scope, result, options, true);
97 Ext.data.PagingMemoryProxy = Ext.ux.data.PagingMemoryProxy;