EXTjs treegrid - 正确的模型

时间:2013-08-15 06:37:05

标签: json extjs nested treegrid

一个非常简单的例子,但它不起作用。工作组列表循环。我究竟做错了什么?如何纠正为这个json写一个模型。文件

http://docs.sencha.com/extjs/4.0.7/#!/api/Ext.data.reader.Reader

以下是截图结果。

https://ps.vk.me/c537518/u155966612/doc/2ee8ec3e7718/1234.png

JS代码。

Ext.define('WorckGroup', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'text', type: 'string', mapping: 'WorckGroup' },
    ],
    hasMany: { name: 'children', model: 'UserReport', associationKey: 'UserReport' }
});

Ext.define('UserReport', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'text', type: 'string', mapping: 'Specialist' },
    ],
    belongsTo: 'WorckGroup'
});


var store = new Ext.data.TreeStore({
    model: 'WorckGroup',
    proxy: {
        type: 'ajax',
        url: '/omnireports/ajaxgrid'
    },
    autoLoad: true,
    folderSort: true
});


Ext.define('basegrid', {
    extend: 'Ext.tree.Panel',
    xtype: 'tree-grid',
    title: 'Core Team Projects',
    height: 300,
    useArrows: true,
    rootVisible: false,
    multiSelect: true,
    singleExpand: false,

    initComponent: function () {
        this.width = 500;

        Ext.apply(this, {
            store: store,
            columns: [{
                xtype: 'treecolumn',
                text: 'Task',
                flex: 2,
                sortable: true,
                dataIndex: 'text'
            },]
        });
        this.callParent();
    }
});

JSON

[{"WorckGroup":"Группа поддержки 3D",
    "UserReport":[
{"Specialist":"Вагин Александр Константинович","SCallCount":64,"AverageDuration":0.1136067,"leaf":true},
{"Specialist":"Кистерева Татьяна Алексеевна","SCallCount":171,"AverageDuration":0.1058641,"leaf":true},
{"Specialist":"Лысенко Алексей Валентинович","SCallCount":71,"AverageDuration":0.4269940,"leaf":true}]},

{"WorckGroup":"Группа поддержки сервиса КСУП",
    "UserReport":[
{"Specialist":"Болгов Руслан Евгеньевич","SCallCount":62,"AverageDuration":0.1093749,"leaf":true},
{"Specialist":"Костин Алексей Алексеевич","SCallCount":17,"AverageDuration":0.1125816,"leaf":true},
{"Specialist":"Мироненко Анна Владимировна","SCallCount":172,"AverageDuration":0.0632347,"leaf":true},
{"Specialist":"Ползиков Мирослав Александрович","SCallCount":315,"AverageDuration":0.0945766,"leaf":true},
{"Specialist":"Тахтенков Николай Владимирович","SCallCount":7,"AverageDuration":0.2342261,"leaf":true}]}

0 个答案:

没有答案