PDA

View Full Version : Ext JS4: Combobox options not being displayed



shruthi123
6 Nov 2014, 6:03 AM
Hi

I have a combobox in the form panel. Initially I had used Ext.data.SimpleStore and now I changed it to Ext.data.Store. After making this change,the values in my combobox are not being displayed.. However, when I press down key to check the values..the number of rows present is right..( I tried changing the store to 3 elements and checked ) only the text is not visible since the height of the row is too less I think.
So, someone please help me to fix it.


{
name : 'cName',
xtype : 'combobox',
displayField : 'name',
valueField : 'code',

store : new Ext.data.Store({
fields : [ 'code', 'name' ],
data : [ [ '1', 'ABCD' ],
[ '2', 'EFGH' ],
[ '3', 'IJKL' ] ,
['4','MNOP']
]
}),


}


Thanks

Tim Toady
6 Nov 2014, 7:34 AM
The store you are now using defaults to using a json reader. The data you have is still set up to be read by an array reader. You need to format your data as key value pairs.

carol.ext
6 Nov 2014, 9:04 AM
Or use an array reader, see code below. If you change to use a model instead of specifying fields on the store, it will help with migration to ExtJS 5.x.


var mystore = new Ext.data.Store({
reader: {
type: 'array'
},
fields: ['code', 'name'],
data: [
['1', 'ABCD'],
['2', 'EFGH'],
['3', 'IJKL'],
['4', 'MNOP']
]

});

console.log(mystore.count());
mystore.each(function(what) {
console.log(what.data);
});

jianmin.liu
7 Nov 2014, 7:52 AM
The store you are now using defaults to using a json reader. The data you have is still set up to be read by an array reader. You need to format your data as key value pairs.

I have the same problem.

jianmin.liu
7 Nov 2014, 7:53 AM
I have the same problem.

I have fixed the problem.

jianmin.liu
7 Nov 2014, 7:59 AM
Thanks.