View Full Version : How to reference a edtor in EditorGridPanel

29 Jun 2011, 6:30 AM
xtype: 'editorgrid',
width: 619,
height: 192,
store: 'StoreCom',
border: false,
ref: '../grid_com',
columns: [
xtype: 'gridcolumn',
dataIndex: 'id',
header: 'Código',
sortable: true,
width: 60,
editor: {
xtype: 'combo',
typeAhead: true,
triggerAction: 'all',
mode: 'remote',
store: 'Store',
valueField: 'id',
displayField: 'name',
ref: '../../combo'
}when I try the driver says this.combo not defined. but if I can refer to this.grid_com.

I have tried different ways and do not get the solution. I hope I can give an idea of how.

I appreciate any help you can offer

30 Jun 2011, 1:52 PM
I don't believe you can use ref like this. From the docs:

ref: A path specification, relative to the Component's ownerCt specifying into which ancestor Container to place a named reference to this Component.

A quick look at the code suggests this is indeed correct. An editor on a grid column is not technically a child component and doesn't have an ownerCt.

You have a few options but the easiest one is just to instantiate the combobox up front. Then you can assign it to whatever you need.

30 Jun 2011, 2:33 PM
Thank you for your response. I get the reference to the editor by id. I just wanted to know if it was possible with ref.

30 Jun 2011, 2:54 PM
The use of Ext.getCmp() with fixed ids is rife in the official examples. It makes them slightly simpler but it is very misleading as it gives the false impression that this is a good way to architect an application. For anything beyond a trivial example I would avoid using ids or Ext.getCmp(). They form a global namespace that frequently causes problems for code reuse. If you really want to use a singleton (and in practice you usually don't), make a properly namespaced singleton, don't do it by the backdoor using ids.

That said, Ext.getCmp() can be very useful for debugging.

30 Jun 2011, 4:59 PM
That told me, so ask if you could do with ref. That I had been told, so wonder if it could do with ref. There are some examples you can see reference to access a editor?

Looking at the api I think this is another way of referring to the editor


That's a good way to do this or is there better?

30 Jun 2011, 5:26 PM
Using getEditor() should work but I don't see it documented anywhere so I'd be wary of it.

I don't really understand the need for any of this complexity. Just do:

var combo = new Ext.form.ComboBox({...});

... {
xtype: 'editorgrid',
columns: [
editor: combo

Within the current function you'll then have combo as a reference to your combobox. If you need to save combo on another object (like using ref would) then just save it on that object with something like:

this.combo = combo;

30 Jun 2011, 6:25 PM
This is true not documented. I saw him was in the Dom. I tried it and it worked. In the doc api only appear getCellEditor().

Thanks for response. I'll do as you say.

Dom screenshot


I got the definition of the method in src / widgets / grid / Column.js

getEditor: function(rowIndex){
return this.editable !== false ? this.editor : null;