首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ext JsonStore与JsonStore

Ext JsonStore与JsonStore
EN

Stack Overflow用户
提问于 2016-04-20 15:15:03
回答 1查看 359关注 0票数 0

在比较了这两个类的文档之后,我想知道为什么要使用Ext.data.JsonStore而不是它的超类: Ext.data.Store。这些文档描述了关于JsonStore的以下内容:

小助手类,使从JSON数据创建Ext.data.Stores更容易。JsonStore将自动配置为一个Ext.data.reader.Json。

然后,文档显示了JsonStore的典型配置如下:

代码语言:javascript
复制
var store = new Ext.data.JsonStore({
    // store configs
    autoDestroy: true,
    storeId: 'myStore',

    proxy: {
        type: 'ajax',
        url: 'get-images.php',
        reader: {
            type: 'json',
            root: 'images',
            idProperty: 'name'
        }
    },

    //alternatively, a Ext.data.Model name can be given (see Ext.data.Store for an example)
    fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
});

上面的代码显式地将读取器类型设置为' json‘--难道不是在JsonStore中隐含了json类型吗?在我看来,这种配置与配置代理在Ext.data.Store实例中读取JSON文件的方式并没有什么不同。

我是否误解了Ext.data.JsonStore的使用?如果不是,在Ext.data.Store上使用它有什么好处?

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2016-04-20 16:51:40

看一下Ext.data.JsonStore的定义

代码语言:javascript
复制
Ext.define('Ext.data.JsonStore',  {
    extend: 'Ext.data.Store',
    alias: 'store.json',
    requires: [
        'Ext.data.proxy.Ajax',
        'Ext.data.reader.Json',
        'Ext.data.writer.Json'
    ],

    constructor: function(config) {
        config = Ext.apply({
            proxy: {
                type  : 'ajax',
                reader: 'json',
                writer: 'json'
            }
        }, config);
        this.callParent([config]);
    }
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36748165

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档