PDA

View Full Version : SimpleStore Load



Valentina
7 Aug 2009, 12:02 AM
Hi All,

I would like to load a SimpleStroe from a JsonReader but it dosn't work.

Here are my jsondata:


{"success":true,"arrival":[{"port":"ANTWERP","portcode":"BEANR","date":"20.05.2009"},{"port":"OSLO","portcode"
:"NOOSL","date":"24.05.2009"},{"port":"LARVIK","portcode":"NOLAR","date":"25.05.2009"},{"port":"NHAVA
SHEVA (JAWAHAR","portcode":"INNSA","date":"03.05.2009"},{"port":"ARHUS","portcode":"DKAAR","date":"25
.05.2009"},{"port":"GOTHENBURG","portcode":"SEGOT","date":"27.05.2009"}],"departure":[{"port":"SHANGHAI"
,"portcode":"CNSHA","date":"17.04.2009"},{"port":"YANGZHOU","portcode":"CNYZH","date":"09.04.2009"},
{"port":"ZHANGJIAGANG","portcode":"CNZJG","date":"09.04.2009"},{"port":"WUHAN","portcode":"CNWUH","date"
:"03.04.2009"}]}

I need the root departure.

I've tried it like this:


var dsdep = new Ext.data.SimpleStore(
{fields: [ {name: 'port', mapping: 'port'},
{name: 'portcode', mapping: 'portcode'},
{name: 'date', mapping: 'date'}
]});
var depArray =stvvarival.reader.jsonData.departure;
dsdep.loadData(depArray);

Can somebody help me please?

Condor
7 Aug 2009, 12:09 AM
Ext.data.SimpleStore is an Ext.data.Store with a preconfigured Ext.data.ArrayReader.

However, your data consists of objects and not arrays.

So you need an Ext.data.Store with an Ext.data.JsonReader (or you could use an Ext.data.JsonStore).

Valentina
7 Aug 2009, 12:35 AM
Yes, but is there another way ? because I want do load this store a second time.

Is there a way that I can change the root of a Jsonstore?

Thanks

Condor
7 Aug 2009, 12:48 AM
That's a completely different question. So you want to be able to change the root of a JsonReader?

You could use:

delete store.reader.ef;
store.reader.root = 'myroot';
store.reader.buildExtractors();

Valentina
7 Aug 2009, 3:39 AM
Hi Condor,

Thank you very much.

Have a nice day.