PDA

View Full Version : Array to ArrayStore



avivenna
20 Sep 2012, 7:51 PM
Hello,

I was trying to populate ArrayStore by using an Array. The Array structure as follows

arr[1]['field1'] = 123,
arr[1]['field2']= 456,
arr[1]['field3']= 'name'

I want field1, field2, field3 vales in ArrayStore. It seems like a silly one but still I am unable to achieve it. any ideas please? Thanks for looking into the thread. Comments Appreciated

Thanks,
Avi

vijayasarathi
20 Sep 2012, 8:29 PM
follow the following array store structure :


[
{'fname':arr[1][field1],'fname':arr[1][field2],...},
{'fname':arr[2][field1],'fname':arr[2][field2],...},
{'fname':arr[3][field1],'fname':arr[3][field2],...},
{'fname':arr[4][field1],'fname':arr[4][field2],...},


]

vijayasarathi
21 Sep 2012, 4:27 AM
try this one..........


var store =Ext.create (http://docs.sencha.com/ext-js/4-1/#!/api/Ext-method-create)('Ext.data.ArrayStore (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.ArrayStore)',{// store configs storeId:'myStore',// reader configs fields:['company',{name:'price', type:'float'},{name:'change', type:'float'},{name:'pctChange', type:'float'},{name:'lastChange', type:'date', dateFormat:'n/j h:ia'}]});

so here you add your code ............

var myData =[

['price':arr[1][field1],'change':arr[1][field2],'pctChange':arr[1][field3],'lastChange':arr[1][field4],...],

['price':arr[2][field1],'change':arr[2][field2],'pctChange':arr[2][field3],'lastChange':arr[2][field4],...],
['price':arr[3][field1],'change':arr[3][field2],'pctChange':arr[3][field1],'lastChange':arr[3][field2],...]


]];