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: "width: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 ‘  这是肿么回事???

 

 

转载于:https://www.cnblogs.com/ccding13/p/3168673.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值