zoukankan      html  css  js  c++  java
  • 20. Extjs学习笔记——Ext.data.JsonStore使用说明

    Ext.data.JsonStore继承于Ext.data.Store,使得从远程JSON数据创建stores更为方便的简单辅助类。JsonStore合成了Ext.data.HttpProxy与Ext.data.JsonReader两者。如果你需要其他类型的proxy或reader组合,那么你要创建以Ext.data.Store为基类的配置。
    代码实例:

    1
    2
    3
    4
    5
    6
    7
    <code class="hljs lasso">var store = new Ext.data.JsonStore({
        id:'id',
        url: 'get-images.php',
        root: 'images',
        totalProperty: 'rowCount',
        fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
    });</code>
    他的返回值将形成如下的对象:
    1
    2
    3
    4
    5
    6
    7
    <code class="hljs css">
    {
        images: [
            {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)},
            {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)}
        ]
    }</code>

    下面我们依次说明下几个参数的含义:
    id(String):用来唯一标识
    url(String):如果有值传入,会为该URL创建一个HttpProxy对象
    root(String):JSON对象的key指定,这里指的是服务器传递过来的json变量的命名
    totalProperty:这里指的是查询出来的条数,也是由服务器传递过来
    fields(Object[]):对象数组集合
    在实际应用中fields我们可以使用遍历list等方式往里面传值。

  • 相关阅读:
    Oracle错误——ORA-12704:字符集不匹配
    nodejs 错误问题解决
    windows 卸载 node.js 怎么卸载搜索
    Git安装配置及基本使用(windows)
    破解photoshop cs6 mac
    将text中的数字转换为字符串
    JavaScript 为什么不推荐使用 eval?
    Permission denied (publickey).
    linux 命令
    恢复 git reset -hard 的误操作
  • 原文地址:https://www.cnblogs.com/sharpest/p/7561980.html
Copyright © 2011-2022 走看看