ext JS 6 中的 hasMany 自动关系

hasMany auto relation in ext JS 6

我正在尝试使用 Ext js 6 在同一实体中实现一个简单的 parent children 关系,我将在 JSON 中接收所有信息。它对 parent 工作正常,但我无法在网格中显示 children。我想这真的很简单,错误应该在模型中:

Ext.define('hashmanytest.model.Person', {
extend: 'Ext.data.Model',
alias: 'model.Person',


 hasMany: {
    model: 'hashmanytest.model.Person',
    name: 'childs',
    associationKey: 'childs'
 },



fields: [
    { name:'name' , type:'string' },
    { name:'email' , type:'string' },
    { name:'phone' , type:'string' },
    { name:'id' , type:'string' },
    { name: 'parent', reference: 'hashmanytest.model.Person'}
]
});

或在店内:

Ext.define('hashmanytest.store.Personnel', {
extend: 'Ext.data.Store',

alias: 'store.personnel',

model: 'hashmanytest.model.Person',

data: { items: [
    { name: 'Jean Luc', email: "jeanluc.picard@enterprise.com", phone: "555-111-1111", id:1, parent: {}, childs: [
        { name: 'Worf',     email: "worf.moghsson@enterprise.com",  phone: "555-222-2222", id:2},
        { name: 'Deanna',   email: "deanna.troi@enterprise.com",    phone: "555-333-3333", id:3},
        { name: 'Data',     email: "mr.data@enterprise.com",        phone: "555-444-4444", id:4}
    ]},
    { name: 'Worf',     email: "worf.moghsson@enterprise.com",  phone: "555-222-2222", id:2, parent:{ name: 'Jean Luc', email: "jeanluc.picard@enterprise.com", phone: "555-111-1111", id:1}, childs: []},
    { name: 'Deanna',   email: "deanna.troi@enterprise.com",    phone: "555-333-3333", id:3, parent:{ name: 'Jean Luc', email: "jeanluc.picard@enterprise.com", phone: "555-111-1111", id:1}, childs: []},
    { name: 'Data',     email: "mr.data@enterprise.com",        phone: "555-444-4444", id:4, parent:{ name: 'Jean Luc', email: "jeanluc.picard@enterprise.com", phone: "555-111-1111", id:1}, childs: []}
]},

proxy: {
    type: 'memory',
    reader: {
        type: 'json',
        rootProperty: 'items'
    }
}
});

无论如何,我创建了一个 fiddle 实现: https://fiddle.sencha.com/#fiddle/11gr

任何帮助将不胜感激

模型不错,record.childs()returns一个store。使用 getCount() 而不是 length:

{
     text: 'Children',
     sortable: true,
     flex: 2,
     renderer: function (value, metaData, record) {
         return record.childs().getCount();    
     }
}

https://fiddle.sencha.com/#fiddle/11gs