2012-11-01 130 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