PDA

View Full Version : store with memory vs. ajax proxy



re_buchanan
5 Jan 2011, 11:17 AM
I'm having trouble figuring out why my store with a memory proxy is not loading exactly the same as my store with an ajax proxy. Both are loading the same data and using the same model, but the memory proxied store does not seem to be loading the model.

here's a snippet:


var fieldList = [
{name: 'LOC_TYPE', type: 'string'}
,{name: 'OPEN_CLOSED', type: 'string'}
,{name: 'id', type: 'string'}
,{name: 'loc_id', type: 'string'}
,{name: 'text', type: 'string'}
]

Ext.regModel('exec', {
fields: fieldList
,hasMany: {model: 'corp', name: 'corps'}
});

Ext.regModel('corp', {
fields: fieldList
,hasMany: {model: 'group', name: 'groups'}
,belongsTo: 'exec'

});

Ext.regModel('group', {
fields: fieldList
,hasMany: {model: 'division', name: 'divisions'}
,belongsTo: 'corp'
});

Ext.regModel('division', {
fields: fieldList
,hasMany: {model: 'branch', name: 'branches'}
,belongsTo: 'group'
});

Ext.regModel('branch', {
fields: fieldList
,hasMany: {model: 'team', name: 'teams'}
,belongsTo: 'division'
});

Ext.regModel('team', {
fields: fieldList
,belongsTo: 'branch'
});



var rollupTree = new Ext.data.Store({
model: 'exec'
,proxy: {
type: 'ajax'
,url: service_directory + 'rollup.rootedTree'
,reader: {
type: 'json'
,root: 'exec'
}
}
});

var rollupTreeNew = new Ext.data.Store({
model: 'exec'
,proxy: {
type: 'memory'
,reader: {
type: 'json'
,root: 'exec'
}
}
});


later the following statements load the data:

rollupTree.load();
rollupTreeNew.loadData(user.rolluptree);

(FYI, user is a global variable that is load on login - the user.rolluptree property contains exactly the same information as is returned by the ajax call to rollup.rootedTree)

I can elaborate further if need be.

Thanks

re_buchanan
5 Jan 2011, 11:54 AM
amazing how I always manage to find a solution after I post to the forums here. for the record:

changed it to autoLoad:true and provided the data in the definition (slightly altered) and it works like a champ now.


var rollupTreeNew = new Ext.data.Store({
autoLoad: true
,model: 'exec'
,data: {exec: user.rolluptree}
,proxy: {
type: 'memory'
,reader: {
type: 'json'
,root: 'exec'
}
}
});


still not sure why what I was doing before didn't work