ExtJS json store not populating

↘锁芯ラ 提交于 2019-12-12 02:57:30

问题


I've recently taken a dive into ExtJS by inheriting a web app written in 3.4. I've managed to create a store attached to a grid with no problem and have been able to bring up a PanelForm with data loaded from a call to a php page.

I have another json store defined which doesn't get populated when I call its load procedure and I'm wondering what I am missing.

The definition of the store is below:

var ImgStore = new Ext.data.JsonStore({
 totalProperty: 'total'
,root: 'data'
,url : 'json/getProductImage/'        
,fields : [{
    name : 'img'
},{
    name : 'extn'
}]
});

My code to load the data is:

ImgStore.load({callback: function() {}            
        ,params: {'ProductGUID': x}
    });

The code behind the URL is fine and the response in Firebug below:

{"success":true,"data":{"img":"iVBORw0KG...ggg==","extn":"png"}}

What I cannot understand is why the response comes back but the Store does not populate. I must be missing something; I just can't see what...

Does the Store have to be bound to another object? What I wanted to do was to read back the base64 encoded string and then show the image on screen (on either a panel, FormPanel or Container; not really sure of the best method really)

Any advice is greatly received.


回答1:


Your store needs a model. The model needs to reflect the attributes that are then being returned in your JSON feed. Only then will the data show up in your store.




回答2:


Everything looks fine, except for the url config aren't u missing the name of the file ? 'json/getProductImage/myfile.json'?

How are you validating store is not loaded by binding it to a grid? Because if so, store could be loading but not configuring grid properly might make u think store is not loaded, try console.log(store.getTotalCount())



来源:https://stackoverflow.com/questions/25572954/extjs-json-store-not-populating

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!