Skip to content
Snippets Groups Projects
Commit 762553a7 authored by legac's avatar legac
Browse files

ExtJS 4.2: gridfilter almost working.

parent 37787064
No related branches found
No related tags found
No related merge requests found
...@@ -40,15 +40,6 @@ Ext.define('App.data.DirectStore', { ...@@ -40,15 +40,6 @@ Ext.define('App.data.DirectStore', {
var proxy; var proxy;
/*
// keep a copy of the initial where condition
if (cfg.baseParams.hasOwnProperty('where')) {
cfg.initialWhere = [];
for (i = 0; i < cfg.baseParams.where.length; i += 1) {
cfg.initialWhere.push(cfg.baseParams.where[i]);
}
}
*/
// the proxy // the proxy
if (!config.proxy) { if (!config.proxy) {
proxy = { proxy = {
...@@ -58,6 +49,14 @@ Ext.define('App.data.DirectStore', { ...@@ -58,6 +49,14 @@ Ext.define('App.data.DirectStore', {
config.proxy = proxy; config.proxy = proxy;
} }
// copy of the initial where condition
if (this.extraParams && this.extraParams.where) {
this.initialWhere = [];
for (i = 0; i < this.extraParams.where.length; i += 1) {
this.initialWhere.push(this.extraParams.where[i]);
}
}
// initialise the base class // initialise the base class
this.callParent(arguments); this.callParent(arguments);
...@@ -76,16 +75,19 @@ Ext.define('App.data.DirectStore', { ...@@ -76,16 +75,19 @@ Ext.define('App.data.DirectStore', {
}, },
/** /**
* Handler to update the total number of records after a write action * Handler to update the total number of records after a write action.
*
* @param {Ext.data.Store} store * @param {Ext.data.Store} store
* @param {String} action * @param {Ext.data.Operation} operation
* Understood action are *create* and *destroy*. * Understood action are *create* and *destroy*
* @param {Object} eOpts
*
*/ */
onWrite: function (store, action) { onWrite: function (store, operation, eOpts) {
"use strict"; "use strict";
switch (action) { switch (operation.action) {
case 'create': case 'create':
store.totalLength += 1; store.totalLength += 1;
break; break;
...@@ -106,16 +108,16 @@ Ext.define('App.data.DirectStore', { ...@@ -106,16 +108,16 @@ Ext.define('App.data.DirectStore', {
var i; var i;
if (this.baseParams.hasOwnProperty('where')) { if (this.extraParams.where) {
if (this.initialWhere) { if (this.initialWhere) {
this.baseParams.where = []; this.extraParams.where = [];
for (i = 0; i < this.initialWhere.length; i += 1) { for (i = 0; i < this.initialWhere.length; i += 1) {
this.baseParams.where.push(this.initialWhere[i]); this.extraParams.where.push(this.initialWhere[i]);
} }
} else { } else {
delete this.baseParams.where; delete this.extraParams.where;
} }
} }
} }
......
...@@ -223,7 +223,13 @@ Ext.define('App.grid.GridFilter', { ...@@ -223,7 +223,13 @@ Ext.define('App.grid.GridFilter', {
} }
// push new condition in the where clause of the store // push new condition in the where clause of the store
this.store.baseParams.where = conditions; if (conditions.length) {
this.store.extraParams.where = conditions;
// go back to the initial where setting when conditions are empty
} else {
this.store.restoreWhere();
}
}, },
// private method to load the store applying filter conditions // private method to load the store applying filter conditions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment