PDA

View Full Version : Add plugin after grid has loaded



leoman730
28 Sep 2010, 7:37 AM
Is there a way to add plugin for a grid after the grid has loaded in extjs? I have trouble where I use extjs designer tool to create a grid; however, there's no option in the designer tool where i can specify the plugin. I'd like to find a way to do it programmingly, anyone has any idea how would I do it? Thanks in advance.

plalx
28 Sep 2010, 11:37 AM
You can have a plugin that adds a listener to the afterrender event of the grid...

E.g.



GridPlugin = function() {
return {
init: function(grid) {
grid.on({
'afterrender': function() {
//Do something
console.log('plugin exec');
}
});
}
};
};

/*
//You must pass your plugin when instanciating the grid
new Ext.grid.GridPanel({
...
plugins: [
new GridPlugin()
]
});
*/

wemerson.januario
1 Oct 2010, 4:30 PM
use this private method initPlugin().
It does not have in docs api.

myComponente.initPlugin(new myPlugin(), new myAnotherPlugin());
or


myComponente.initPlugin(new myPlugin({
config1: 'ExtJS',
config2: 'Brazilllllll'
}));

plalx
1 Oct 2010, 5:16 PM
I think it is normally not a good idea to rely on private and undocumented functions since they might change in any further releases...