zoukankan      html  css  js  c++  java
  • ExtJS -- ArrayStore

    ArrayStore :

     1 // Store for array
     2     var myStore = new Ext.data.ArrayStore({
     3       storeId: "arrayStore",
     4       fields: ["ID", "Name"],
     5       data: [        //Data Source
     6           ["1", "Array"],
     7           ["2", "Json"],
     8           ["3", "Xml"]
     9       ]
    10     });
    11 
    12     // Grid to display the Data
    13     var myGrid = new Ext.grid.GridPanel({
    14         renderTo: Ext.getBody(),
    15         title: "Demo of Grid",
    16         style: "400px; margin:10px;",
    17         autoHeight: true,
    18         store: Ext.StoreMgr.lookup("arrayStore"),
    19         columns: {
    20             items:[
    21                 { header: "ID", dataIndex: "ID"},
    22                 { header: "Name", dataIndex: "Name"}
    23             ],
    24             defaults:{    // here, apply default config to each column
    25                 align: "center"
    26             }
    27         }
    28     });

    其中,关于 [store: Ext.StoreMgr.lookup("arrayStore")], 参考: http://kandy0619.blog.163.com/blog/static/6434434520091111104339833/

    这个Store, 还可以这样创建:

    //Data Source
    var arrayData = [
        [1, "Array"],
        [2, "Json"],
        [3, "Xml"]
    ];
    // fields
    var arrFields = [ 
        { name: "ID", mapping:0, type: "int"},
        { name: "Name", mapping:1, type: "string"}
    ];
    //Store Container
    var myStore = new Ext.data.Store({
        storeId: "arrayStore",
        data: arrayData,
        fields: arrFields,
        proxy:{
            type: "memory",
            reader:{
                type: "array"
            }
        }
    });

    但是, 下面的这个就出错, 还是定义的问题?

    var myStore = new Ext.data.Store({
        storeId: "arrayStore",
        //autoLoad: true,
        proxy: new Ext.data.MemoryProxy(arrayData),
        reader: new Ext.data.ArrayReader({id: 0}, arrFields)
    });

    直接不显示, 连个提示都木有???

    又添加了: 

    myStore.loadData(arrayData);

    Error: ’ TypeError: c is not a constructor ‘  这是肿么回事???

  • 相关阅读:
    PS_0005:画带颜色在线条框 按住Alt键复制
    零钱兑换(动态规划)
    倒排索引原理和实现
    集群搭建
    java内部类
    nohup &后台运行脚本
    scala构造函数
    spark数据源读取及读数据原理
    安装redis解决公司linux环境的坑
    61、对于employees表中,给出奇数行的first_name
  • 原文地址:https://www.cnblogs.com/ccding13/p/3168673.html
Copyright © 2011-2022 走看看