PDA

View Full Version : jsonstore with loaddata



michaelc
5 Jan 2012, 5:37 PM
I had this working in 3 but seems to not load in 4.0


// Speciality Object reader
var reader = new Ext.data.JsonStore({
root: 'dataObj',
fields: [{
name: 'Grouping'
}, {
name: 'Specialty'
}, {
name: 'SPECIALTY_ID'
}, {
name: 'Value'
}, {
name: 'Intrest'
}]
});

reader.loadData(specialtiesAreaDataObj);


any idea on what needs to be changed ?
does this now require a memory proxy - no I don't think so.

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.Memory

any help ?

slemmon
5 Jan 2012, 8:18 PM
Is
specialtiesAreaDataObj an array of objects or model instances?

skirtle
5 Jan 2012, 9:23 PM
var store = Ext.create('Ext.data.Store', {
fields: ['Grouping', 'Specialty', 'SPECIALTY_ID', 'Value', 'Interest'],
data: [
{Grouping: 1, Specialty: 2, SPECIALTY_ID: 3, Value: 4, Interest: 5},
{Grouping: 6, Specialty: 7, SPECIALTY_ID: 8, Value: 9, Interest: 0}
]
});

or:


var store = Ext.create('Ext.data.Store', {
fields: ['Grouping', 'Specialty', 'SPECIALTY_ID', 'Value', 'Interest']
});

store.loadData([
{Grouping: 1, Specialty: 2, SPECIALTY_ID: 3, Value: 4, Interest: 5},
{Grouping: 6, Specialty: 7, SPECIALTY_ID: 8, Value: 9, Interest: 0}
]);

If you want to do things involving a root then you'll need a proxy and a reader, possibly a memory proxy if that's where your data is (though it strikes me as easier just to pull the data out of the root instead).

michaelc
6 Jan 2012, 9:24 AM
Got it - the changes in 4.0 are all very subtle and sensible.
thanks