2

我正在使用 ExtJS 4.0.7,并且正在使用 JSON Store 将其加载到 Panel Grid。我正在使用 Firefox 版本 16.0.2。这是一个非常简单的例子,我能够运行阵列网格。

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":"jsmith@example.com"},
      { "id": 2, "name":"Anna Smith", "email":"asmith@example.com"},
      { "id": 3, "name":"Peter Smith", "email":"psmith@example.com"},
      { "id": 4, "name":"Tom Smith", "email":"tsmith@example.com"},
      { "id": 5, "name":"Andy Smith", "email":"asmith@example.com"},
      { "id": 6, "name":"Nick Smith", "email":"nsmith@example.com"}
    ]}
  });   


 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'
      }
    ]

});

});

网格正在加载,没有数据显示。它显示一个空白网格。我不确定这个问题。是不是因为浏览器兼容性问题?

4

1 回答 1

1

你的商店是本地的。不要使用属性

var Grid1Store = new Ext.data.JsonStore({
  fields: [ 'id', 'name', 'email' ],
  autoLoad: true,
  data: [ 
    { "id": 1, "name":"John Smith", "email":"jsmith@example.com"},
    { "id": 2, "name":"Anna Smith", "email":"asmith@example.com"},
    { "id": 3, "name":"Peter Smith", "email":"psmith@example.com"},
    { "id": 4, "name":"Tom Smith", "email":"tsmith@example.com"},
    { "id": 5, "name":"Andy Smith", "email":"asmith@example.com"},
    { "id": 6, "name":"Nick Smith", "email":"nsmith@example.com"}
  ]
});   
于 2012-11-01T02:23:35.520 回答