3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
16 /* Fix for Opera, which does not seem to include the map function on Array's */
17 if (!Array.prototype.map) {
18 Array.prototype.map = function(fun){
19 var len = this.length;
20 if (typeof fun != 'function') {
21 throw new TypeError();
23 var res = new Array(len);
24 var thisp = arguments[1];
25 for (var i = 0; i < len; i++) {
27 res[i] = fun.call(thisp, this[i], i, this);
34 Ext.ns('Ext.ux.data');
36 <div id="cls-Ext.ux.data.PagingMemoryProxy"></div>/**
37 * @class Ext.ux.data.PagingMemoryProxy
38 * @extends Ext.data.MemoryProxy
39 * <p>Paging Memory Proxy, allows to use paging grid with in memory dataset</p>
41 Ext.ux.data.PagingMemoryProxy = Ext.extend(Ext.data.MemoryProxy, {
42 constructor : function(data){
43 Ext.ux.data.PagingMemoryProxy.superclass.constructor.call(this);
46 doRequest : function(action, rs, params, reader, callback, scope, options){
51 result = reader.readRecords(this.data);
54 this.fireEvent('loadexception', this, options, null, e);
55 callback.call(scope, null, options, false);
60 if (params.filter !== undefined) {
61 result.records = result.records.filter(function(el){
62 if (typeof(el) == 'object') {
63 var att = params.filterCol || 0;
64 return String(el.data[att]).match(params.filter) ? true : false;
67 return String(el).match(params.filter) ? true : false;
70 result.totalRecords = result.records.length;
74 if (params.sort !== undefined) {
75 // use integer as params.sort to specify column, since arrays are not named
76 // params.sort=0; would also match a array without columns
77 var dir = String(params.dir).toUpperCase() == 'DESC' ? -1 : 1;
78 var fn = function(v1, v2){
79 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
81 result.records.sort(function(a, b){
83 if (typeof(a) == 'object') {
84 v = fn(a.data[params.sort], b.data[params.sort]) * dir;
90 v = (a.index < b.index ? -1 : 1);
95 // paging (use undefined cause start can also be 0 (thus false))
96 if (params.start !== undefined && params.limit !== undefined) {
97 result.records = result.records.slice(params.start, params.start + params.limit);
99 callback.call(scope, result, options, true);
104 Ext.data.PagingMemoryProxy = Ext.ux.data.PagingMemoryProxy;