PDA

View Full Version : Data store preloaded, but updatable through ajax



Entropy
1 Nov 2011, 9:39 AM
Hello,

So I have a data store. When the page initially loads, I want it load the data store from data that is part of the page load. But later on, it will update via ajax. So I set the data property and filled in a proxy. It's not working at load time (haven't gotten far enough to check later loads). Are these incompatible? Or am I making some other mistake?


Ext.define('_feedback_ds_model', {

extend: 'Ext.data.Model',

fields: [

{name: 'level', type: 'int'},
{name: 'levelAsString', type: 'string'},

{name: 'message', type: 'auto'}

] });




Ext.create('Ext.data.Store', {
storeId:'_feedback_ds',

model:'_feedback_ds_model',
proxy: {

type: 'ajax',

url: myUrl,

reader: {

type: 'json',

root: 'data',

}

},

data: {

success: true,

data: [

{level:'400',levelAsString:'ERROR',message:'OMG! It\'s an error! Run!'},

{level:'300',levelAsString:'WARNING',message:'So, look out behind you. Or don\'t. I don\'t care.'},

{level:'200',levelAsString:'INFO',message:'This is some information. You have been informed.'}

] }

});

Entropy
1 Nov 2011, 10:12 AM
I ended up using a MemoryProxy on initial load and then calling setProxy with a remote proxy immediately thereafter. That seemed to work. Is there a way to load the regular proxy up with initial data? If not, this certainly solves the problem.

whalethewise
1 Nov 2011, 10:51 AM
I think you can try to use loadData() or loadRawData() to do initial load. And then call load() to use Proxy