PDA

View Full Version : Activate a plugin



nick saint
9 Aug 2009, 5:08 AM
Hi, I have a grid which I would like to make editable on demand by means of plugins: [editor] at the GridPanel.
I figured it this way: I apply a button to tbar and if it's pressed the RowEditor activates.

tbar:[{
id: 'editTCbtn',
iconCls: 'edit',
enableToggle: true,
pressed: false,
tooltip: 'Press to star editing the data.',
toggleHandler: function (btn, pressed) {
if(pressed == true){
grid.plugins = [editor];
}
},
scope: this
}...Please, give an idea how to make it work
Thank you
Nick

Animal
9 Aug 2009, 5:17 AM
Remember that grid.plugins might already exist. But it might not.

So you have to be prepared to either create the Array, or add to it.

And you know how to set it up. Ths plugins config option's documentation has



The only requirement for a valid plugin is that it contain an init method that accepts a reference of type Ext.Component. When a component is created, if any plugins are available, the component will call the init method on each plugin, passing a reference to itself.

nick saint
9 Aug 2009, 5:55 AM
something like this?


toggleHandler: function (btn, pressed) {
if(pressed == true){
var plugins = [editor];
Ext.each(this.plugins, function(p, i) {
plugins[i] = this.initPlugin(p);
}, this);
TCgrid.plugins = plugins;
alert('done');
}
},
scope: this...

Animal
9 Aug 2009, 6:05 AM
No. Read the code and understand what you wrote.

nick saint
9 Aug 2009, 6:26 AM
toggleHandler: function (btn, pressed) {
if(pressed == true){
TCgrid.initPlugin(editor);
}
else{
How to make it stop?
}
},
scope: this