vmorale4
17 Feb 2009, 3:11 PM
Hi, this is my first plug-in. Its purpose is very simple: display the current selection count of a grid in a toolbar.
You can configure the count text, as well as whether it should use the bottom or the top toolbar (by default it uses bbar).
Ext.namespace('Ext.ux.grid');
/**
* Ext.ux.grid.SelCount plugin for Ext.form.GridPanel
*
* @author vmorale4
* @date February 17, 2009
*
* @class Ext.ux.grid.SelectionCount
* @extends Ext.util.Observable
*/
//Note: this override will become obsolete in Ext 3.0
Ext.override(Ext.Toolbar.TextItem, {
setText : function(t){
Ext.fly(this.getEl()).update(t);
}
});
Ext.ux.grid.SelCount = function(config) {
Ext.apply(this, config);
};
Ext.extend(Ext.ux.grid.SelCount, Ext.util.Observable, {
bar:'bbar',
countText:'{0} row(s) selected',
defaultText:'No rows selected',
init:function(grid) {
this.grid=grid;
var sm= grid.getSelectionModel();
grid.on('render',function(){
var b=(this.bar=='bbar'?grid.getBottomToolbar(): grid.getTopToolbar());
b.addSeparator();
this.countItem=b.addText(this.defaultText);
},this);
sm.on('selectionchange',function(){
this.countItem.setText(String.format(this.countText,sm.getCount()));
},this);
}
});
You can configure the count text, as well as whether it should use the bottom or the top toolbar (by default it uses bbar).
Ext.namespace('Ext.ux.grid');
/**
* Ext.ux.grid.SelCount plugin for Ext.form.GridPanel
*
* @author vmorale4
* @date February 17, 2009
*
* @class Ext.ux.grid.SelectionCount
* @extends Ext.util.Observable
*/
//Note: this override will become obsolete in Ext 3.0
Ext.override(Ext.Toolbar.TextItem, {
setText : function(t){
Ext.fly(this.getEl()).update(t);
}
});
Ext.ux.grid.SelCount = function(config) {
Ext.apply(this, config);
};
Ext.extend(Ext.ux.grid.SelCount, Ext.util.Observable, {
bar:'bbar',
countText:'{0} row(s) selected',
defaultText:'No rows selected',
init:function(grid) {
this.grid=grid;
var sm= grid.getSelectionModel();
grid.on('render',function(){
var b=(this.bar=='bbar'?grid.getBottomToolbar(): grid.getTopToolbar());
b.addSeparator();
this.countItem=b.addText(this.defaultText);
},this);
sm.on('selectionchange',function(){
this.countItem.setText(String.format(this.countText,sm.getCount()));
},this);
}
});