Свяжите данные магазина с деревом проверки в Сенче - PullRequest
0 голосов
/ 22 сентября 2018

Я работаю с деревом чеков в сенче.

Это мой магазин

Ext.define('crApp.store.modulesStore', {
    extend: 'Ext.data.TreeStore',
    proxy: {
        type: 'memory'
    },
    model: 'crApp.model.MainTreeModel',
    defaultRootProperty: "children",
    root: {
        expanded: true,
        children: [{"text":"Dashboard","moduleId":"1","checked":true,"expanded":true,"children":[{"permission_id":"3","permission_name":"View","text":"Dashboard/View","moduleId":"1_3","checked":false,"leaf":true}]},{"text":"Master","moduleId":"2","checked":true,"expanded":true,"children":[{"text":"Facility","moduleId":"3","checked":true,"expanded":true,"children":[{"permission_id":"1","permission_name":"Create","text":"Facility/Create","moduleId":"3_1","checked":true,"leaf":true},{"permission_id":"2","permission_name":"Edit","text":"Facility/Edit","moduleId":"3_2","checked":true,"leaf":true},{"permission_id":"3","permission_name":"View","text":"Facility/View","moduleId":"3_3","checked":true,"leaf":true},{"permission_id":"4","permission_name":"Delete","text":"Facility/Delete","moduleId":"3_4","checked":true,"leaf":true},{"permission_id":"5","permission_name":"Allocation","text":"Facility/Allocation","moduleId":"3_5","checked":true,"leaf":true}]},{"text":"Marketing","moduleId":"4","checked":true,"expanded":true,"children":[{"permission_id":"1","permission_name":"Create","text":"Marketing/Create","moduleId":"4_1","checked":true,"leaf":true},{"permission_id":"2","permission_name":"Edit","text":"Marketing/Edit","moduleId":"4_2","checked":true,"leaf":true},{"permission_id":"3","permission_name":"View","text":"Marketing/View","moduleId":"4_3","checked":true,"leaf":true},{"permission_id":"4","permission_name":"Delete","text":"Marketing/Delete","moduleId":"4_4","checked":true,"leaf":true}]},{"text":"Department","moduleId":"5","checked":true,"expanded":true,"children":[{"permission_id":"1","permission_name":"Create","text":"Department/Create","moduleId":"5_1","checked":true,"leaf":true},{"permission_id":"2","permission_name":"Edit","text":"Department/Edit","moduleId":"5_2","checked":true,"leaf":true},{"permission_id":"3","permission_name":"View","text":"Department/View","moduleId":"5_3","checked":true,"leaf":true},{"permission_id":"4","permission_name":"Delete","text":"Department/Delete","moduleId":"5_4","checked":true,"leaf":true}]},{"text":"User","moduleId":"6","checked":true,"expanded":true,"children":[{"permission_id":"1","permission_name":"Create","text":"User/Create","moduleId":"6_1","checked":true,"leaf":true},{"permission_id":"2","permission_name":"Edit","text":"User/Edit","moduleId":"6_2","checked":true,"leaf":true},{"permission_id":"3","permission_name":"View","text":"User/View","moduleId":"6_3","checked":true,"leaf":true},{"permission_id":"4","permission_name":"Delete","text":"User/Delete","moduleId":"6_4","checked":true,"leaf":true}]},{"text":"Doctor","moduleId":"7","checked":true,"expanded":true,"children":[{"permission_id":"1","permission_name":"Create","text":"Doctor/Create","moduleId":"7_1","checked":true,"leaf":true},{"permission_id":"2","permission_name":"Edit","text":"Doctor/Edit","moduleId":"7_2","checked":true,"leaf":true},{"permission_id":"3","permission_name":"View","text":"Doctor/View","moduleId":"7_3","checked":true,"leaf":true},{"permission_id":"4","permission_name":"Delete","text":"Doctor/Delete","moduleId":"7_4","checked":true,"leaf":true}]}]}]
    }
});

Когда я использую статические данные, они работают отлично.Данные поступают с URL-адреса php: http://192.168.1.100:8088/CRApp/yii/web/module/index

Как установить URL-адрес ajax в хранилище, чтобы представление могло динамически обращаться к данным.

Я пробовал это:

proxy: {
    type: 'ajax',
    url: 'http://192.168.1.100:8088/CRApp/yii/web/module/tree',
    reader: {
        type: 'json',
        expanded: true,
        root: 'children'
    }
},

, но он не работает должным образом.Любое решение?

1 Ответ

0 голосов
/ 23 сентября 2018
Ext.define('AppName.store.settings.permissions.GroupPermissionsStore', {
    extend: 'Ext.data.TreeStore',
    alias: 'store.groupPermissionsStore',
    autoLoad: true,
    storeId: 'groupPermissionsStore',
    load : function (options) {
        var successFunction = function (response) {
            var grpStore = Ext.data.StoreManager.get('groupPermissionsStore');
            var resp = Ext.JSON.decode(response.responseText);
            grpStore.setRoot(test);
            }
        };
    //Make ajax call with above function as success function
    Ext.Ajax.request({
        url: "http://192.168.1.100:8088/CRApp/yii/web/module/index",
        cors: true,
        async: calltype,
        withCredentials: true,
        //jsonData: dataPayload,
        method: 'POST',
        success: successFunction,
        failure: function (err) {
           //Call back if the ajax call fails
        }
    });
    }
});

Смена ключа для Tree Store - это метод "setRoot" и загрузка данных.Для работы "Ext.data.StoreManager.get ('groupPermissionsStore')" хранилище добавлено в массив хранилищ в файле приложения "app.js".

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...