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