2012-11-01 124 views
2

我使用的是ExtJS 4.0.7,我正在使用JSON Store将它加载到面板网格。我使用的是Firefox 16.0.2版。这是一个非常简单的例子,我可以运行Array网格。使用JsonStore的ExtJS 4面板网格不加载网格

Ext.onReady(function() { 


var Grid1Store = new Ext.data.JsonStore({ 
    root: 'users', 
    fields: [ 'id', 'name', 'email' ], 
    autoLoad: true, 
    data: { users: [ 
     { "id": 1, "name":"John Smith", "email":"[email protected]"}, 
     { "id": 2, "name":"Anna Smith", "email":"[email protected]"}, 
     { "id": 3, "name":"Peter Smith", "email":"[email protected]"}, 
     { "id": 4, "name":"Tom Smith", "email":"[email protected]"}, 
     { "id": 5, "name":"Andy Smith", "email":"[email protected]"}, 
     { "id": 6, "name":"Nick Smith", "email":"[email protected]"} 
    ]} 
    }); 


var Grid1Grid = new Ext.grid.GridPanel({ 
     store: Grid1Store, 
     renderTo: 'grid-example', 
     title: 'Target', 
     width: 300, 
    columns: [ 
     { 
     id: 'name', 
     header: "Name", 
     sortable: true, 
     dataIndex: 'name' 
     },{ 
     id: 'email', 
     header: "Email", 
     sortable: true, 
     dataIndex: 'email' 
     } 
    ] 

}); 

}); 

表格正在加载并且没有数据显示。它显示一个空格。我不确定这个问题。是否由于某些浏览器兼容性问题?

+0

嗨,欢迎来到StackOverflow。如果你想获得有用的答案,最好是更具体地了解你想知道的内容。 “请检查是否有问题”不是一个问题。 –

回答

1

你的店铺是本地的。请勿使用属性

var Grid1Store = new Ext.data.JsonStore({ 
    fields: [ 'id', 'name', 'email' ], 
    autoLoad: true, 
    data: [ 
    { "id": 1, "name":"John Smith", "email":"[email protected]"}, 
    { "id": 2, "name":"Anna Smith", "email":"[email protected]"}, 
    { "id": 3, "name":"Peter Smith", "email":"[email protected]"}, 
    { "id": 4, "name":"Tom Smith", "email":"[email protected]"}, 
    { "id": 5, "name":"Andy Smith", "email":"[email protected]"}, 
    { "id": 6, "name":"Nick Smith", "email":"[email protected]"} 
    ] 
}); 
+0

它的工作原理。谢谢。 – user1790163

+0

你可以给我代码片段加载它从像sample.json或远程调用文件吗? – user1790163

+0

你应该看看sencha的网格示例。 http://docs.sencha.com/ext-js/4-1/#!/example/grid/array-grid.html – Damask