PDA

View Full Version : [FIXED-254] JsonStore example broken in documentation



twh
30 Aug 2010, 3:32 PM
I've simplified the JsonStore example in the documentation here:

http://dev.sencha.com/deploy/ext/docs/output/Ext.data.JsonStore.html


Ext.setup({
onReady: function() {

var store = new Ext.data.JsonStore({
// store configs
autoDestroy: true,
url: 'get-images.php',
storeId: 'myStore',
// reader configs
root: 'images',
idProperty: 'name',
fields: ['name', 'url', 'size', 'lastmod']
});

}
});

The only thing I changed was wrapping the creation of the store var in an Ext.setup() call and created a get-images.php file which returns a JSON object with name, url, size, and lastmod values. And yet when I load the page, I get this error:

TypeError: Result of expression 'this.model' [undefined] is not an object.

Is there something I'm missing, or is the example incomplete? It isn't clear what other code is necessary to create a store.

evant
30 Aug 2010, 11:30 PM
The code is incorrect in the class, but in a lot of way it's not needed anymore. One of the main reasons it existed is because in Ext there wasn't really a simple way to construct a store with just json, but now you can do:



new Ext.data.Store({
fields: ['name', 'url', 'size', 'lastmod'],
reader: {
root: 'images'
idProperty: 'name'
},
proxy: {
url: 'get-images.php'
}
});


Which isn't really much longer than what we already have.

evant
8 Sep 2010, 10:55 PM
The docs have been updated in 0.94 to reflect the correct usage.