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等方式往里面传值。

  • 相关阅读:
    深入分析String类型(一)
    创建泛型类
    XML数据的读取—数据库配置文件
    Config配置文件读写
    jQuery动画
    设置屏幕快捷键
    jQuery事件
    jQuery操作DOM
    Python 二进制文件网址
    Centos使用crontab自动定时备份mysql的脚本
  • 原文地址:https://www.cnblogs.com/sharpest/p/7561980.html
Copyright © 2011-2022 走看看