0

How can I access the function getTree in my TreeStore-Instance from the configuration of the DirectProxy? Like this etc. nothing works....

Is somebody able to help me?

Ext.define('PM.store.Projects', {
    extend: 'Ext.data.TreeStore',
    model: 'PM.model.Project',
    autoLoad: true,

    /*proxy: {
        type: 'ajax',
        url: 'data/projectTree.json',
        reader: {
            type: 'json',
        },
    },
    root: {
        name: 'Test',
        id: -1,
    }*/

    proxy: {
        type: 'direct',
        directFn: PM.controller.Projects.getTree,
    },

    /*root: {
        name: 'Demo',
        children: [
            {
                name: 'Test',
                leaf: true,
            },
        ],
    },*/

    getTree: function() {
        alert("Test");
    }
});
4

1 回答 1

0

我想你可以在构造函数中构建你的代理。

Ext.define('PM.store.Projects', {
    extend: 'Ext.data.TreeStore',
    model: 'PM.model.Project',
    autoLoad: true,

    constructor: function(config) {
        var me = this;
        Ext.apply(me, config);
        me.proxy = {
            type: 'direct',
            directFn: me.getTree
        };
        me.callParent();
    },

    getTree: function() {
        alert("Test");
    }
});
于 2013-02-21T13:15:16.680 回答