-
14 May 2009 3:11 AM #1
Local array to Simple Store
Local array to Simple Store
Hi,
I am trying to create a simple store out of a local array as follows:
var arr = [];
for(i=1;i<=20;i++)
{
var m = {id:i, lvl: i};
arr.push(m);
}
var storeLevels = new Ext.data.SimpleStore({
fields: [{name:'id', type: 'int'},{name:'lvl',type: 'int'}],
});
storeLevels.loadData(arr);
And here is my combo box definition as follows:
{
xtype: 'combo',
name: 'lvlfrom',
fieldLabel: 'From*',
allowBlank: false,
triggerAction:'all',
readOnly:true,
mode: 'local',
store: storeLevels,
displayField: 'lvl',
valueField: 'id',
width:128
},
But my combo box is displaying 20 items with blank values.
Thanks.
-
14 May 2009 3:56 AM #2
A Simple store reads each row as an Array using an Ext.data.ArrayReader.
You have each row as an Object which would require a Store which used an Ext.data.JsonReaderSearch the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
14 May 2009 4:04 AM #3
As Animals says.
If you want to use a SimpleStore:
PHP Code:var arr = [];
for(i=1;i<=20;i++)
{
var m = {id:i, lvl: i};
arr.push([m.id, m.lvl]);
}
-
14 May 2009 6:36 AM #4
-
11 Mar 2011 1:06 AM #5
is it possible to convert SimpleStore to array?


Reply With Quote