开发者

Ext.data.JsonStore is not a constructor problem

开发者_如何学Go    category_store = new Ext.data.JsonStore({
fields:['category_name','category_id'],
data:Ext.util.JSON.decode('[{"category_name":"SubTemplate 1","category_id":"6"},{"category_name":"Templates","category_id":"5"},{"category_name":"Uncategorized","category_id":"1"}]')
}); 

Gives an error in debug console - Ext.data.JsonStore is not a constructor and if the defug file is not include it tells d is undefined .

So can someone tell me what is the problem.


If you use ExtJS 4 then init your classas via Ext.create what will attempt to load the class, if it has not been defined yet or use Ext.require to load classes. Go to http://docs.sencha.com/ext-js/4-0/#/api/Ext and read about "create" and "require" method


This works fine for me. Please make sure you are wrapping your code in an Ext.onReady call:

Ext.onReady(function() {
    category_store = new Ext.data.JsonStore({
        fields: ['category_name','category_id'],
        data: Ext.util.JSON.decode('[{"category_name":"SubTemplate 1","category_id":"6"},{"category_name":"Templates","category_id":"5"},{"category_name":"Uncategorized","category_id":"1"}]')
    }); 
});

In the future, it is best to post your Ext JS questions over on the Sencha Forums, as you will get a much faster response.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜