2012-01-14 56 views
1

我试图创建一个网格(Ext.grid.Panel)并用数据填充它。但有些事情出错了,网格显示没有数据的空行。空行出现在网格中

型号是:

Ext.define('Order', { 
    extend: 'Ext.data.Model', 
    fields: [ 
     { 
      name: 'id', 
      type: 'int' 
     }, 
     { 
      id: 'companyId', 
      type: 'int' 
     }, 
     { 
      id: 'amount', 
      type: 'int' 
     }, 
     { 
      id: 'dealDate', 
      type: 'date' 
     }, 
     { 
      id: 'complete', 
      type: 'int' //boolean imitation 
     } 
    ], 
    idProperty: 'id' 
}); 

电网&店铺代码:

var orders = Ext.create('Ext.data.Store', { 
    model: 'Order', 
    proxy: Ext.create('Ext.data.proxy.Ajax', { 
     url: 'service/orders-data.php?', 
     reader: Ext.create('Ext.data.reader.Json', { 
      root: 'orders' 
     }) 
    }), 
    sorters: [{ 
     property: 'name', 
     direction: 'ASC' 
    }] 
}); 
orders.load(); 

var ordersGrid = Ext.create('Ext.grid.Panel', { 
    width: 400, 
    height: 300, 
    store: orders, 
    columns: [ 
     { 
      text: 'Amount', 
      dataIndex: 'amount', 
      width: 120 
     }, 
     { 
      text: 'Deal date', 
      dataIndex: 'dealDate', 
      width: 120 
     }, 
     { 
      text: 'Complete', 
      dataIndex: 'complete', 
      width: 120 
     } 
    ] 
}); 

从服务器JSON响应是:

{ 
"orders":[ 
    { 
     "id":1, 
     "amount":5000, 
     "dealDate":"2012-01-05", 
     "complete":0 
    }, 
    { 
     "id":2, 
     "amount":6850, 
     "dealDate":"2012-01-07", 
     "complete":0 
    }, 
    { 
     "id":5, 
     "amount":7400, 
     "dealDate":"2012-01-09", 
     "complete":0 
    } 
] 
} 

为什么网格显示空行?

+0

哪列是空的?他们全部? – 2012-01-14 23:07:45

回答

1

所有模型的字段,但第一个被与“ID”属性宣布,他们应该改为使用“名”:

{ 
    name: 'id', 
    type: 'int' 
}, 
{ 
    name: 'companyId', 
    type: 'int' 
}, 
{ 
    name: 'amount', 
    type: 'int' 
}, 
{ 
    name: 'dealDate', 
    type: 'date' 
}, 
{ 
    name: 'complete', 
    type: 'int' //boolean imitation 
} 
+0

谢谢你,猫头鹰。我似乎真的盲目想念这个错误:) – Artem 2012-01-15 08:15:43