Skip to content
Snippets Groups Projects
Commit 3d4b759a authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

Add the handling of combobox.

Paging is still missing.
parent 9492ba38
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,6 @@ App.grid.GridFilter = Ext.extend(Object, {
* Plugin initialization
*/
init: function(grid){
console.debug('start grid filter plugin');
// link the grid store
this.store = grid.getStore();
......@@ -49,38 +48,49 @@ App.grid.GridFilter = Ext.extend(Object, {
for (var i = 0; i < fields.length; i++){
field = fields[i];
// catch the enter for non combobox field
if(fields.xtype != 'xcombobox' ){
// catch a change of value for combo box
if (field.xtype == 'xcombobox')
field.on('select', this.onSelect, this);
// catch the key pressed enter for other fields
else
field.on('specialkey', this.onSpecialKey, this);
}
}
},
/**
* Handler to catch a new selection in combobox
*/
onSelect: function(combo, record, index){
this.filter(combo);
},
/**
* Handler to catch the ENTER
* @param {Object} field
* @param {Object} e
*/
onSpecialKey: function(field,e){
if (e.getKey() == e.ENTER) {
var value = field.getValue();
var where = field.name + " " + field.filterOperator + " '" + value + "'";
if( value == '')
delete this.filterConditions[field.name];
else
this.filterConditions[field.name] = where;
this.filter();
}
if (e.getKey() == e.ENTER)
this.filter(field);
},
/**
* Filter the data
* @param {Ext.form.Field}
*/
filter: function(){
console.debug('filter the data');
filter: function(field){
// get the field value and update the condition dictionary
var value = field.getValue();
var where = field.name + " " + field.filterOperator + " '" + value + "'";
if( value == '')
delete this.filterConditions[field.name];
else
this.filterConditions[field.name] = where;
// build the complete where clause
var conditions = [];
for( var i = 0; i < this.initialFilterConditions.length; i++){
conditions.push(this.initialFilterConditions[i]);
......@@ -89,7 +99,8 @@ App.grid.GridFilter = Ext.extend(Object, {
for( k in this.filterConditions){
conditions.push(this.filterConditions[k]);
}
// update the store
this.store.baseParams.where = conditions;
this.store.load();
}
......
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