PDA

View Full Version : How to add dinamically a plugin to a Column Cell Editor



dtex-lab
15 Nov 2011, 6:15 AM
Hi

I know I can add a plugin on the fly to a TextField (for example) in the following way.



vField = .... < a text field retrieved)
var vPlugin = new Ext.ux.MyPlugin();
vPlugin.init(vField);


It is working fine
But now I need to add it to a textfield used as an editor for a editable grid panel

I tried the following code but without lucky



vRoot = .....;
var vGrid = vRoot.findByItemId('MyGrid');
var vColumnModel = vGrid.getColumnModel();
var vColumnIndex = vColumnModel.findColumnIndex("MyColumn");
var vColumn = vColumnModel.getColumnAt(vColumnIndex);
if(vColumn.editor)
{
var vField = vColumn.editor;
var vPlugin = Ext.ux.MyPlugin();
vPlugin.init(vField);
//vColumn.setEditor(vField);
}


But it doesn't works..
In my case the init method is implemented in this way



init: function(aField)
{
this.field = aField;
this.field.on('render', function()
{
this.field.el.on('keyup', this.onKeyup, this);
}, this);
},


I need to add the keyup event to the editor field.

Any idea ?

p.s. if I add the plugin to the field creating the column model.. it is working fine.. but I need to add it at runtime (after creating the grid etc etc)
Thanks

mitchellsimoens
18 Nov 2011, 1:37 PM
where are you trying to add this plugin? In your 2nd code snippet, is vField an actual field instance or a config object?

dtex-lab
19 Nov 2011, 7:20 AM
Hi
vField is an instance of a TextField exacly like the code in 1st snippet.

The issue is only for a editor grid (editor for a column). Adding dynamically as in 1st snippet in a simple form it is working fine

It seems that there is something related to the "activation" of the cell field editor
thanks