Skip to content

Instantly share code, notes, and snippets.

@edspencer
Created July 24, 2009 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edspencer/154144 to your computer and use it in GitHub Desktop.
Save edspencer/154144 to your computer and use it in GitHub Desktop.
/**
* @class ExtMVC.view.scaffold.Index
* Adds a print button to each grid (remove by setting the hasPrintButton config to false)
*
* This is an example in support of http://edspencer.net/2009/07/extoverride-monkey-patching-ext-js.html
*/
(function() {
var originalBuildTopToolbar = ExtMVC.view.scaffold.Index.prototype.buildTopToolbar;
Ext.override(ExtMVC.view.scaffold.Index, {
hasPrintButton : true,
buildTopToolbar: function() {
var items = originalBuildTopToolbar.apply(this, arguments);
if (this.hasPrintButton === true) {
/**
* @property printButton
* @type Ext.Button
* The Print grid button
*/
this.printButton = new Ext.Button({
text : 'Print',
iconCls: 'print',
scope : this,
handler: GetIt.GridPrinter.print.createDelegate(this, [this])
});
items.push(this.printButton, '-');
}
return items;
}
);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment