PDA

View Full Version : ComboBox with Blank Options



paulharv
19 Jul 2010, 4:45 AM
Hi,

I'm using a ComboBox as the editor of a Column in a grid, and its options list is getting generated, but it's completely blank.

This is the JSON I'm getting back from the server...


{"results": 3, "hashes": [{"value": "0", "label": "Hey"}, {"value": "1", "label": "You"}, {"value": "2", "label": "There"}]}And this is the relevant excerpt from my code:


var cm = new Ext.grid.ColumnModel({
columns: [
{
header: 'Category',
width: 120,
editor: new Ext.form.ComboBox({
typeAhead: true,
store: new Ext.data.JsonStore({
url: 'categories',
root: 'hashes',
fields: ['value','label']
}),
triggerAction: 'all'})
}
]
})

With this JSON and this code I get a dropdown list with 3 blank options...(if the JSON has 4 elements in it, I get 4 blank options)...

This is how the DOM looks..



<div id="ext-gen129" class="x-combo-list-inner" style="overflow: auto; width: 116px; height: 18px;">
<div class="x-combo-list-item"/>
<div class="x-combo-list-item"/>
<div class="x-combo-list-item x-combo-selected"/>
</div>
Can anyone see what I'm mssing?!

Thanks so much,

Paul

Condor
19 Jul 2010, 5:03 AM
You are missing the displayField (and optionally the valueField) config options of the ComboBox.

paulharv
19 Jul 2010, 6:29 AM
Thanks very much.

Condor
19 Jul 2010, 6:46 AM
displayField is a config option of ComboBox and not of JsonStore!

paulharv
19 Jul 2010, 6:48 AM
Just realized that when re-reading my post...was hoping you wouldn't read it before I edited it to just say thanks!!
Thanks very much.