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

First version of pGridExpertMenu which required and improved version of

the GridFilter. Remove the obsolete pGridExport.
parent 8b9a638e
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@
dbui.configure_grids(db, plugins=['pGridRowEditorConfirmDelete',
'pGridRowEditorContextMenu',
'pGridRowEditorDblClick',
'pGridExport'])
'pGridExpertMenu'])
#
# Polish categories grid
#
......
......@@ -48,7 +48,7 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
},
/**
* private method requests by the component model of Ext JS
* private method requests by the component model of ExtJS
*/
initComponent: function () {
......@@ -56,7 +56,7 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
fields,
i;
// initialize the underlying class.
// initialise the underlying class.
App.grid.GridFilter.superclass.initComponent.call(this);
// associate handlers to fields
......@@ -103,13 +103,23 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
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);
},
/**
* Handler to catch a change in field value
*/
onChange: function (field) {
// setup the filter conditions
this.setupCondition(field);
// update the store
this.updateStore();
},
/**
......@@ -117,15 +127,26 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
*/
onReset: function () {
var fields,
i;
// reset field values and filter conditions
this.reset();
// update the store
this.updateStore();
},
/**
* Reset the filter
*/
reset: function () {
// reset the field value
fields = this.findByType('field');
var fields = this.findByType('field'),
i;
// reset the field values
for (i = 0; i < fields.length; i += 1) {
fields[i].reset();
}
// reset filter conditions
this.filterConditions = {};
......@@ -140,11 +161,8 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
if (this.pagingToolbar) {
this.pagingToolbar.pageSize = 10;
}
// update the store
this.updateStore();
},
/**
* Setup condition
* @param {Ext.form.Field}
......@@ -191,9 +209,6 @@ App.grid.GridFilter = Ext.extend(Ext.form.FieldSet, {
// push new condition in the where clause of the store
this.store.baseParams.where = conditions;
// update the store
this.updateStore();
},
/**
......
/**
* The grid expert menu plugin for toolbar
* The ptype of this component is pGridExpertMenu.
*
*/
Ext.namespace('App.grid');
App.grid.ExpertMenu = Ext.extend(Object, {
/**
* Private parameter identifying the type of plugin
*/
ptype: 'pGridExpertMenu',
/**
* Private attribute for internationalisation
*/
textExport: 'Export to CSV file',
textReset: 'Reset',
/**
* Plugin initialisation
*/
init: function(grid){
var bbar = grid.getBottomToolbar(),
menu;
menu = new Ext.Toolbar.SplitButton({
menu:{
items: [{
listeners: {click: this.onReset, scope: grid},
text: this.textReset
}, {
href: App.csvUrl + '?tableName=' + App.getTableName(grid.store),
text: this.textExport
}]
}
});
bbar.add('->', menu);
},
/**
* Handler to reset filter and to reload the underlying data store
*/
onReset: function () {
var grid = this,
store = this.getStore();
// remove gridFilter conditions
delete store.baseParams.where;
// send the clear signal in order to reset gridFilter
store.fireEvent('clear');
// load the store with fresh data
store.load();
}
});
Ext.preg('pGridExpertMenu', App.grid.ExpertMenu);
/**
* The grid export plugin for toolbar
* The ptype of this component is pGridExport.
*
* @version
*
*/
Ext.namespace('App.grid');
App.grid.Export = Ext.extend(Object, {
/**
* Private parameter identifying the type of plugin
*/
ptype: 'pGridExport',
/**
* Private attribute for internationalization
*/
textExport: 'Export to CSV file',
/**
* Plugin initialization
*/
init: function(grid){
var bbar = grid.getBottomToolbar()
bbar.add(
'->', {
xtype: 'xbuttondownload',
iconCls: 'xaction-export',
tooltip: this.textExport,
url: App.csvUrl + '?tableName=' + App.getTableName(grid.store)
}
);
}
});
Ext.preg('pGridExport', App.grid.Export);
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