View Full Version : Combo displayField valueField?
cluettr
7 Sep 2007, 9:57 AM
Hello all,
Just need someone to clarify why this combobox works the way it does. If I set the displayField and value Fields to something different then it does not show the correct value after edit (it shows the valueField). In other words. The value in the drop down is the displayField and when I select it it populates the grid cell with the valueField? Why would it do this?
froamer
15 Sep 2007, 10:38 PM
if you are using the ComboBox in a grid, it is only visible when editing. After the edit, the grid is rendering the value. You need to add a renderer as well as an editor to your column model. Here is an example...
header: 'Company Type',
width: 120,
sortable: true,
dataIndex: 'company_type_id',
editor: new Ext.grid.GridEditor(
new Ext.form.ComboBox(
{
typeAhead: false,
triggerAction: 'all',
lazyRender: false,
store: company_types_ds,
displayField: 'name',
valueField: 'id'
}
)
),
renderer:
function(data) {
record = company_types_ds.getById(data);
if(record) {
return record.data.name;
} else {
return data;
}
}
In my example there is a datasource called company_types_ds which has an id and a name. The renderer looks up the record by the id (the value) and renders the name. If it cannot find a record of that id it returns the original data (the id).
If you haven't had chance to watch Scott Walter's excellent screen casts on the grid, I highly recommend you do. He covers most of what you need to know to create a fully functional grid interface.
These can be found in the Learn section of this site under Screen Casts.
cluettr
16 Sep 2007, 7:27 PM
Not refering to the combobox within a grid but thank you anyway.
froamer
17 Sep 2007, 12:09 AM
Then I don't understand the problem...
The value in the drop down is the displayField and when I select it it populates the grid cell with the valueField?
What do you mean by grid cell if you are not referring to the combobox within a grid?
Perhaps you could explain further or post some code and I will try to help.
mystix
17 Sep 2007, 1:38 AM
@cluettr, i just replied in another thread about how the ComboBox works in the grid.
see this thread:
http://extjs.com/forum/showthread.php?p=63721#post63721
cluettr
18 Sep 2007, 5:37 PM
My bad, I have multiple posts, one for a grid and another for the form.combobox. I got these two messed up. Sorry about that and thank you for the reponse.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.