View Full Version : EditorGridPanel, ComboBox as editor and remote data source

23 Nov 2007, 8:50 AM
Hi all,
I searched on the ExtJs documentation and on the examples, but I don't understand how to do one thing.

I have an EditorGridPanel, which loads data from remote using a Store.
For a given column I have id and label, where id is a numeric key, and label is the label to show to the user. I don't have any way to translate from the first to the second on the client (the id is a sequence number more or less).
Initially I put an object in the Store with the format {id: "id", label: "label"}, then I defined a renderer to only show the label and the Grid happily shows only the label.
The troubles began when I tried editing the column. It seems that it's not possible to use objects as values in a ComboBox, because String(Object) is always [object Object] and so the value is never changed in the Store (look the onEditComplete method of EditorGridPanel)
On the other hand, if the Combo returns the label, I don't have the id anymore, if it returns the id, I'm not able to render anymore.
Probably I need 2 columns in the Store, but then how can I update the second when the user updates the first?

Do you have some ideas?
Thanks a lot in advance

28 Nov 2007, 1:41 AM
Hi all, I'm posting this only to let you know how I solved the problem.
I patched some places in Ext 2.0 rc1 to allow editong of Objects.
The idea is that yo compare 2 objects Ext.util.JSON.encode(object) is surely better of String(object).

I patched the set method of Ext.data.Record, the onEditComplete method of Ext.grid.EditorGridPanel, the completeEdit method of Ext.Editor to change the way values are compared.
Than I discovered that the startEdit method of Ex.Editor was calling this.filed.setValue and not setValue, and I patched this one too.

After all this I derived (and this is code that belongs to my application) Ext.Editor to redefine the setValue and getValue method, in which I changed into the string value to pass to the Combo the object *in the set), and then from the string value to the objet (in the get) and all worked.

If someone needs itI can send a patch (against 2.0 rc1) of the patched methods.