0

Сервер возвращает такой сложный объект. На самом деле данных внутри больше, но суть понятна, есть объекты и у них есть наследники.

{"data":
{"accesslist":
[{"id":1,"parentID":0,"groupName":"doctor","pointCode":"patient.view","pointName":"Patien data","pointDescription":"","children":
[{"id":2,"parentID":1,"groupName":"doctor","pointCode":"patient.personal.info","pointName":"Show patient data","pointDescription":""}]
}]
}
}

Мне нужно разместить этот объект в GridPanel, можете подсказать, как это сделать? Выводить в GridPanel надо pointName или pointDescription.

Я пробовал так, но это не работает.

var fullAccessCarribean = Ext.create('Ext.data.TreeStore', {
    proxy: {
        url: '/CardioService/securitymanager',
        method: 'post',
        type: 'ajax',
        extraParams:{
            mode: 'accesslist',
        },
        reader: {
            root: 'data.accesslist'
        }
    },
    root:{
        expanded: true,
    }
});


Ext.define('Ext.Modules.AdminGridForm.SettingsPanel.AccessPanel.AccessTreeGrid.AccessTreeGrid', {
    extend: 'Ext.tree.Panel',    
    alias: 'widget.accesstreegrid',

    flex: 1,

    layout: {
        type: 'hbox',
        align: 'stretch'
    },

    store: fullAccessCarribean,
});

1 ответ 1

0

Это не работает потому, что у вас отсутствует описание данных. Оно должно выпоняться в хранилище либо через модель Ext.data.Model, либо, в случае если полей немного можно прямо в хранилище(ваш случай) в поле fields:

Ext.create('Ext.data.TreeStore', {
fields: ['pointName', 'pointDescription'],
proxy: {
    url: '/CardioService/securitymanager',
    method: 'post',
    type: 'ajax',
    extraParams:{
        mode: 'accesslist',
    },
    reader: {
        root: 'data.accesslist'
    }
},
root:{
    expanded: true,
}});

Также в вашем дереве отсутствует описание колонок:

....
columns: [{
    text: 'pointDescription',
    dataIndex: 'pointDescription'
}, {
    text: 'pointName',
    dataIndex: 'pointName'
}]
....

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.