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

グリッドに空の行が表示されるのはなぜですか?

4

1 に答える 1

1

最初のフィールドを除くすべてのモデルのフィールドは、代わりに「name」を使用する必要がある「id」プロパティで宣言されています。

{
    name: 'id',
    type: 'int'
},
{
    name: 'companyId',
    type: 'int'
},
{
    name: 'amount',
    type: 'int'
},
{
    name: 'dealDate',
    type: 'date'
},
{
    name: 'complete',
    type: 'int' //boolean imitation
}
于 2012-01-15T02:11:00.637 に答える