ExtJS 6.2.0, treestore, как определить последние элементы в узлах и установить для них leaf: true?
У меня существует treepanel:
{
xtype: 'treepanel',
store: {
type: 'tree',
model: 'view.treemodel',
parentIdProperty: 'parent_id',
autoLoad: true,
proxy: {
type: 'ajax',
headers: { "Content-Type": 'application/json' },
actionMethods: {
read: 'GET',
update: 'POST'
},
api: { read: 'app/view/store.json' },
reader: {
type: 'json',
rootProperty: 'result',
successProperty: 'success',
totalProperty: 'total'
}
},
root: {
id: 0,
name: 'root',
expanded: true,
nodeType: 'async'
}
},
columns: [
{
xtype: 'treecolumn',
dataIndex: 'name'
}
]
}
Стор к нему (store.json)
{
"result": [
{
"id": 1,
"parent_id": null,
"name": "Задача 1"
},
{
"id": 2,
"parent_id": null,
"name": "Задача 2"
},
{
"id": 3,
"parent_id": null,
"name": "Задача 3"
},
{
"id": 4,
"parent_id": 1,
"name": "11"
},
{
"id": 5,
"parent_id": 2,
"name": "22"
},
{
"id": 6,
"parent_id": 4,
"name": "33"
}
],
"total": 6,
"success": true,
"message": ""
}
и модель:
Ext.define('view.treemodel', {
extend:'Ext.data.Model',
idProperty:'id',
fields:[
{name:'id', type:'auto', defaultValue:null },
{name:'name', type:'auto'}
]
});
Выглядит это так:
"33", "22" и "Задача 3" не содержат дочерних элементов и не должны иметь возможности на раскрытие
Подскажите, как установить для последних элементов дерева параметр leaf: true и почему они не проставляются автоматически?
P.S.: пробовал в reader прописывать
transform: {
fn: function(data) {
Ext.Array.each(data.result, function(datum) {
и как-то менять, но в сторе нет явных признаков по которым можно добавить leaf: true
P.S.S.: пробовал в моделе
{ name:'leaf', type:'boolean',
convert: function(val, rec){
...
}
}
но тоже так и не понял как вычислить последние элементы в ветке. Буду благодарен за любую оказанную помощь)
