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

Add the configuration parameter nRows, the method reset and the event

resetgrid.
parent a1300cc3
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,18 @@ Ext.namespace('App.grid');
App.grid.Grid = Ext.extend(Ext.grid.GridPanel, {
/**
* @cfg nRows integer
* Default number of rows display in the grid.
* This parameter is only use when running with a paging plugin.
*/
nRows: 10,
/**
* @event resetgrid
* Can be used to reset underlying plugin when the reset
* method is triggered
*/
/**
* private attributes used by plugins
*/
......@@ -49,18 +61,60 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, {
// empty toolBar requires by the plugins
this.bbar = new Ext.Toolbar();
// initialize the underlying class. DON'T MOVE
// initialise the underlying class. DON'T MOVE
App.grid.Grid.superclass.initComponent.call(this);
// load the store if not yet done
// if the grid paging is used load only the first 10 rows
if (!this.store.getTotalCount()) {
if (App.isPlugin(this, 'pGridPaging')) {
this.store.load({params: {start: 0, limit: 10}});
this.store.load({params: {start: 0, limit: this.nRows}});
} else {
this.store.load();
}
}
},
/**
* reset the grid
* The store is load with fresh data and the event 'resetgrid' is emitted.
* Paging and slider plugin might be reset using the 'resetgrid' event.
* GridFilter object can be also reset using the same mechanism.
*
* The scope is the grid
*
*/
reset: function () {
var action,
i;
// private function to emitt the resetgrid event
function fireReset() {
this.fireEvent('resetgrid');
}
// parameters for the store load action
action = {callback: fireReset, scope: this};
if (this.getBottomToolbar() instanceof Ext.PagingToolbar) {
action.params = {start: 0, limit: this.nRows};
}
// restore initial where condition of the store
// in order to remove filter condition
if ('where' in this.store.baseParams) {
if (this.store.initialWhere) {
this.store.baseParams.where = [];
for (i = 0; i < this.store.initialWhere.length; i += 1) {
this.store.baseParams.where.push(this.store.initialWhere[i]);
}
} else {
delete this.store.baseParams.where;
}
}
// reload the store and fire the resetgrid event
this.store.load(action);
}
});
......
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