Skip to content
Snippets Groups Projects
Commit 6866ac76 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Replace the private attribute initialFilterConditions by the

initialWhere attribute of the store. Use the method store.restoreWhere
as well.
parent f179fe04
No related branches found
No related tags found
No related merge requests found
......@@ -14,16 +14,10 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
/**
* Private
* Dictionary with additional where clause
* Dictionary with where clause related to the filter resquest
*/
filterConditions: {},
/**
* Private
* Initial where clause
*/
initialFilterConditions: [],
/**
* Private
* Reference to the paging toolBar
......@@ -32,7 +26,7 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
/**
* Private
* a reference to the grid store
* Reference to the grid store
*/
store: null,
......@@ -96,22 +90,14 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
this.pagingToolbar = grid.getBottomToolbar();
}
// initial filter conditions
baseParams = this.store.baseParams;
if ('where' in baseParams) {
for (i = 0; i < baseParams.where.length; i += 1) {
this.initialFilterConditions.push(baseParams.where[i]);
}
}
// reset filter when the store emit the clear event
// NOTE: require when the pGridBasicMenu reset the store.
// In that case, the filter avec to be reset too.
this.store.on('clear', this.reset, this);
// reset filter when receiving resetgrid event
// The main user case is when the pGridExpertMenu is triggered
// to reset the grid. In that case, the filter avec to be reset too.
grid.on('resetgrid', this.reset, this);
},
/**
* Handler to catch a change in field value
* Handler to catch a change in field value and to filter the store
*/
onChange: function (field) {
......@@ -123,19 +109,22 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
},
/**
* Handler to reset the filter
* Handler to reset the filter and the store content
*/
onReset: function () {
// reset field values and filter conditions
this.reset();
// restore initial where condition of the store
this.store.restoreWhere();
// update the store
this.updateStore();
},
/**
* Reset the filter
* Reset the filter conditions
*/
reset: function () {
......@@ -149,22 +138,10 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
// reset filter conditions
this.filterConditions = {};
if (this.initialFilterConditions.length > 0) {
this.store.baseParams.where = this.initialFilterConditions;
} else {
delete this.store.baseParams.where;
}
// reset the page size to the default value
if (this.pagingToolbar) {
this.pagingToolbar.pageSize = 10;
}
},
/**
* Setup condition
* Setup filter conditions
* @param {Ext.form.Field}
*/
setupCondition: function (field) {
......@@ -197,8 +174,10 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
}
// build the complete where clause
for (i = 0; i < this.initialFilterConditions.length; i += 1) {
conditions.push(this.initialFilterConditions[i]);
if (this.store.initialWhere) {
for (i = 0; i < this.store.initialWhere.length; i += 1) {
conditions.push(this.store.initialWhere[i]);
}
}
for (k in this.filterConditions) {
......
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