PDA

View Full Version : [SOLVED] Custom GridEditor



kgmoney
17 Jul 2008, 6:50 AM
Hi,

I could swear I've seen discussions on this but now I can't find any. At a high level, I am wondering how I would go about making my own GridEditor--what to extend/override etc. A very basic example of what I would to do is put an object such as...

{ varA: 'hello', varB: 'there' }
into a field on my store. I have a render that displays the value of varA in my EditorGridPanel. When I click the cell to edit it, I would like to be able to edit my object, or just a part of the object. For example, a text field might popup with the value of varA, and when the I'm finished editing the object would be...

{ varA: 'new value', varB: 'there' }

Any thoughts?

Thanks,
Kevin

mjlecomte
17 Jul 2008, 7:43 AM
Really not sure what you're looking for, but maybe you want something like Saki's recordform plugin at www.extjs.eu. You could get it to show up automatically by binding it to the beforeedit event perhaps. You'll probably have to return false to stop the standard editor from firing. All guesses.

kgmoney
17 Jul 2008, 10:43 AM
Hi,

Thanks for the guesses :) I'll try to explain a little better...

So first of all you can store an object in a field in a store, right...like { varA: 'hello', varB: 'there' }. If this store is used with a grid, this field would be displayed something like '[OBJECT]'. This I have fixed with the renderer to just show something in the grid that makes sense, for example the value of varA.

That's all easy, but now I would like to use an EditorGridPanel and be able to edit my object. If I set the editor to be a TextField, I get a text box with '[OBJECT]' in it. So I think I need a custom editor that will know how to edit the object.

Maybe I need to make a new type of form field...and use it for the editor? I'll have a look at that approach.

devnull
17 Jul 2008, 11:35 AM
im sure you could extend a form field to have its setValue() method access a specific property of the passed object. you will of course also have to make sure the getValue() method returns a modified version of the original object as well.

kgmoney
4 Aug 2008, 6:57 AM
That worked. I extended TextField and overrided the getValue() and setValue() members as you mentioned and it works nicely. I also had to add some logic to handle the old value since it is an object.

Thanks for the tips.