PDA

View Full Version : why combox can't show displayfield on editorgrid



kusoft.net
30 Jan 2008, 4:52 PM
4205

Question?
help me,thanks

When I get focus in cell,it will show displayfield value '业务一部', lost focus it will show value field '003',
I want to get and lost always show displayfield value '业务一部'.
(2)But when i update data,I will use value field as hidden value. display field only show.

catacaustic
30 Jan 2008, 5:36 PM
ComboBox editors in EditorGridPanels return the valueField value to the cell, not the displayField. That's the biggest problem with ComboBox's in EditorGridPanels that there is so far, and the only answer to it is to use a custom renderer with that column that can get the displayField value from the data store that is attached to the ComboBox. It's a bit of a long-way-around trip to get what should be easy, but this is one of those things that doesn't seem to have had to much thought put into it by the developers so far unfortunately.

LeonardoAP
31 Jan 2008, 3:31 AM
Its a bit of coding, but is easy to understand



//Combo Renderer
comboRenderer= function(value) {
var record = yourComboName.store.getById(value);
return record ? record.get('text') : '';
};

//Combo Definition
var yourComboName= new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'yourHtmlSelectID',
lazyRender:true,
listClass: 'x-combo-list-small',
displayField: 'text',
valueField: 'value',
id: 'value'
});

//Combo Column
var comboColumn = {
header: 'yourHeader',
dataIndex: 'yourDataIndex',
width: 150,
renderer: comboRenderer,
editor: yourComboName
};

graveyardfashions
31 Jan 2008, 7:13 AM
Ha! I had exactly the same question. Thank you!