动态商店模型网格列

时间:2015-03-30 20:17:40

标签: extjs

网格看起来显示的行数正确且列标题正确但单元格中的实际数据为空白。知道为什么会这样吗?

数据

var data = new DOMParser().parseFromString('<sio><sql><row><Name>item 1</Name><Dn>value 1</Dn></row><row><Name>item 2</Name><Dn>value 2</Dn></row></sql></sio>',"text/xml");
var columns=JSON.parse('[{"dataIndex": "Name","text": "NEW Clumn Name"},{"dataIndex": "Dn","text": "NEW Column Dn"}]');
var fields = JSON.parse('[{"name": "Name","type": "string"},{"name": "Dn","type": "string"}]');

模型

var model = new Ext.data.Model({
    fields: fields
});

新模式

Ext.define('testModel', {
    extend: 'Ext.data.Model',
    requires: [
        'Ext.data.field.String',
    ],
    fields: fields
});

存储

var store = new Ext.data.Store({
    // model: model, // this not works
    model: 'testModel', // this works
    // fields: fields, // this works
    proxy: {
        type: 'memory',
        reader: {
            type: 'xml',
            rootProperty: 'sql',
            record: 'row'
        }
    }
});

var grid = new Ext.grid.GridPanel({
                    xtype: 'gridpanel',
                    title: 'Test',
                    titleAlign: 'center',
                    columnLines: true,
                    id: 'testGrid',
                    forceFit: true,
                    store: store,
                });

负载

grid.reconfigure(store,columns);
store.loadRawData(data);
console.log(fields);

log $ reference:undefined - 任何想法是什么意思

[Object, Object]
  0: Object
    $reference: undefined
    name: "Name"
    type: "string"

0 个答案:

没有答案