2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
9 /* Fix for Opera, which does not seem to include the map function on Array's */
\r
10 if(!Array.prototype.map){
\r
11 Array.prototype.map = function(fun){
\r
12 var len = this.length;
\r
13 if(typeof fun != "function"){
\r
14 throw new TypeError();
\r
16 var res = new Array(len);
\r
17 var thisp = arguments[1];
\r
18 for(var i = 0; i < len; i++){
\r
20 res[i] = fun.call(thisp, this[i], i, this);
\r
27 /* Paging Memory Proxy, allows to use paging grid with in memory dataset */
\r
28 Ext.data.PagingMemoryProxy = function(data) {
\r
29 Ext.data.PagingMemoryProxy.superclass.constructor.call(this);
\r
33 Ext.extend(Ext.data.PagingMemoryProxy, Ext.data.MemoryProxy, {
\r
34 load : function(params, reader, callback, scope, arg) {
\r
35 params = params || {};
\r
38 result = reader.readRecords(this.data);
\r
40 this.fireEvent("loadexception", this, arg, null, e);
\r
41 callback.call(scope, null, arg, false);
\r
46 if (params.filter!==undefined) {
\r
47 result.records = result.records.filter(function(el){
\r
48 if (typeof(el)=="object"){
\r
49 var att = params.filterCol || 0;
\r
50 return String(el.data[att]).match(params.filter)?true:false;
\r
52 return String(el).match(params.filter)?true:false;
\r
55 result.totalRecords = result.records.length;
\r
59 if (params.sort!==undefined) {
\r
60 // use integer as params.sort to specify column, since arrays are not named
\r
61 // params.sort=0; would also match a array without columns
\r
62 var dir = String(params.dir).toUpperCase() == "DESC" ? -1 : 1;
\r
63 var fn = function(v1, v2){
\r
64 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
\r
66 result.records.sort(function(a, b) {
\r
68 if (typeof(a)=="object"){
\r
69 v = fn(a.data[params.sort], b.data[params.sort]) * dir;
\r
74 v = (a.index < b.index ? -1 : 1);
\r
80 // paging (use undefined cause start can also be 0 (thus false))
\r
81 if (params.start!==undefined && params.limit!==undefined) {
\r
82 result.records = result.records.slice(params.start, params.start+params.limit);
\r
85 callback.call(scope, result, arg, true);
\r