PDA

View Full Version : ComboBox value in a EditorGrid?



HeathT
2 Aug 2007, 8:39 PM
How can I reference the value of a comboBox in an EditorGrid?



...



function getColumnModel() {
if(!columnModel) {
columnModel = new Ext.grid.ColumnModel(
[
{
header: 'Cuisine',
width: 125,
sortable: true,
dataIndex: 'cuisine_id',
editor: new Ext.grid.GridEditor(cbCuisine),
renderer: function(value, p, record){
return record.data['cuisine_name'];
}
}
]
);
}
return columnModel;
}

function buildGrid() {
gridForm = new Ext.BasicForm(
Ext.get("updategrid"),
{

}
);

grid = new Ext.grid.EditorGrid(
'mygrid',
{
ds: ds,
cm: getColumnModel(),
autoSizeColumns: false,
trackMouseOver: true,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true})
}
);

...
}


I believe this code snippet is enough to help with the answer - if it's too short let me know.

Thanks in advance!

catacaustic
2 Aug 2007, 8:56 PM
If I'm right (and I may well not be... ;)), in the config for the combo box, you should have:
name: "fieldname"This tells the grid, and the form if you use it with that, the name of the field. From there you should be able to get the value.

HeathT
2 Aug 2007, 10:35 PM
Thanks catacaustic!

Let me give that a shot!

bd318
3 Aug 2007, 12:44 AM
Here is a combobox example:



var combo = new Ext.form.ComboBox({
store: store,
displayField: 'name',
readOnly: true,
valueField: 'value',
loadingText: 'Loading data',
triggerAction: 'all',
mode: 'remote',
emptyText:'Selecteer name',
width:135
});


displayField is the value that you see in the combobox
valueField is the value of the selected field

(in HTML it's: <option value="valueField">displayField</option>)

to acces the values:

combo.getRawValue() = value of displayField
combo.getValue() = value of valueField

HeathT
3 Aug 2007, 8:07 AM
Perfecto!

The .getValue() is exactly what I was looking for.