PDA

View Full Version : Define plugin after rendering



prodigy7
1 Sep 2009, 12:45 AM
Hi,

I create a window:
winHandler = new Ext.Window({
id : 'content',
width : 950,
height : 675,
title : 'text',
border : false,
maximizable : true,
minimizable : true,
resizable : true,
modal : true,
layout : 'fit',
columnLines : true,
plain : true,
items : [ new Ext.grid.GridPanel({
id : 'gridpanel',
layout : 'fit',
border : false,
stateful : false,
store : myStore,
trackMouseOver: true,
disableSelection: false,
loadMask : true,

// grid listeners
listeners: {
celldblclick : function(grid, rowIndex, colIndex) {
alert(rowIndex+' - '+colIndex);
}
},

// grid columns
columns: myColumnsConfig,

// customize view config
viewConfig: myViewConfig,

// paging bar on the bottom
bbar: new Ext.PagingToolbar({
pageSize: 25,
store: myStore,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display",
items: myBottomBar
}),

plugins: [ searchToolbar ]
})]
});

winHandler.show(Ext.getCmp('groupcut'));
This works. Now - I want assign the plugin "searchToolbar" during runtime and not during creating. I tried with something like that
Ext.getCmp('gridpanel').plugins = [ searchToolbar ];
Ext.getCmp('gridpanel').render();but without success. How I can set the plugin after rendering?

Greetz
prodigy7

Animal
1 Sep 2009, 1:52 AM
If you read what plugins do, and read the source of the plugin you'd get it.

Plugins have an init method which is called passing its client Component.

So you can call that.

But if you call it after render, check that the plugin does not rely on a render event being fired to kick off its processing.

Could be that if you want a plugin to be initilizable upon a rendered Component, you have to (horrors!) do some plugin authoring!!!!!

prodigy7
1 Sep 2009, 2:43 AM
Okay ... maybe also my solution is the wrong way for my problem. What I want: I've an variable, which contains true or false. If it contains true, the plugin should be used, if it contains false, it shouldn't used.

I think, i found a solution - before I create the window, I do that:

if(abc)
{
var pluginSpace = [ searchToolbar ];
} else
{
var pluginSpace = [ ];
}Then I replace in my sample
plugins: [ searchToolbar ] with
plugins: [ pluginSpace ] and now it works how I like.

Maybe only for my interest: Is there maybe another, comparable (more charming) solution?

Animal
1 Sep 2009, 3:10 AM
That is the correct way. Build the Array and pass it.

Animal
1 Sep 2009, 3:11 AM
or



{
...
plugins: abc? [ searchToolbar ] : null,
...
}

jay@moduscreate.com
1 Sep 2009, 3:58 AM
Prodigy, when a grid panel is a child of another panel (windows too), you need not call its render method.