【问题标题】:Call function in ExtJs TreeStoreExtJs TreeStore 中的调用函数
【发布时间】:2013-02-21 13:07:45
【问题描述】:

如何通过 DirectProxy 的配置访问 TreeStore-Instance 中的函数 getTree?像这样等。没有任何作用....

有人可以帮助我吗?

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");
    }
});

【问题讨论】:

    标签: extjs extjs4


    【解决方案1】:

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

    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");
        }
    });
    

    【讨论】:

    • 我已更改,但警报未执行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-07
    相关资源
    最近更新 更多