View Full Version : Best Practices: Row/Cell Editing Plugin on GridPanel

29 Jun 2012, 11:45 AM

I have added an editor to a column in my GridPanel:

xtype : 'combo',
triggerAction : 'all',
displayField : 'name',
valueField : 'id',
store: 'MyStore'

Now when I click to edit the cell or row, I make my selection from the combobox, and then update it. The rendered cell value is the 'id' field of my combo, and not the 'name' field. What is the best way to make the GridPanel show the 'name' field? Obviously I don't want to make 'id' and 'name' the same value...that would negate the point of having an id.

I'm keeping a hidden ID field on the GridPanel to match the 'id' field in the editor, and the editor is on the column that would map to the 'name' field. So when the edit is complete, the editor's selected record would populate the hidden ID, and the editing column would show the 'name' field in the renderer.


29 Jun 2012, 1:16 PM
You can create a renderer that has an array of names and use the value to return the correct element.

Another approach I use often is to create a join and return the name itself. This makes it easier to search the string name as well.