【问题标题】:TreePanel in ExtJs with direct proxy behaves weird具有直接代理的 ExtJs 中的 TreePanel 行为怪异
【发布时间】:2013-12-23 15:13:04
【问题描述】:

我正在使用 Sencha Architect 3.0.1。 我正在尝试使用模型、TreeStore 和 TreePanel。

模型:

Ext.define('User.model.ModelClientList', {
    extend: 'Ext.data.Model',
    fields: [{ name: 'id' }, { name: 'name' }, { name: 'status' } ],
    proxy: {
        type: 'direct',
        directFn: 'UserClient.listClient',
        reader: { type: 'json',root: 'data'}
    }
});

树店:

Ext.define('User.store.StoreClientList', {
    extend: 'Ext.data.TreeStore',
    constructor: function(cfg) {
        var me = this;
        cfg = cfg || {};
        me.callParent([Ext.apply({
            model: 'User.model.ModelClientList',
            storeId: 'StoreClientList'
        }, cfg)]);
    }
});

还有 TreePanel:

{
    xtype: 'treepanel',
    height: 250,
    itemId: 'MainClient',
    width: 400,
    title: 'Clients',
    hideHeaders: false,
    store: 'StoreClientList',
    rootVisible: false,
    viewConfig: {loadMask: true},
    columns: [
        {xtype: 'treecolumn',dataIndex: 'name',text: '..'},
        {xtype: 'gridcolumn', dataIndex: 'status', text: '..'}
    ]
}

对 UserClient.listClient 的 json 请求返回:

{
"data":[
    {"id":1,"name":"Pluto","status":3,"children":[
        {"id":35,"name":"Mela","status":2,"leaf":true},
        {"id":36,"name":"Pera","status":1,"leaf":true},
        {"id":37,"name":"Arancia","status":1,"leaf":true}]},
    {"id":2,"name":"Pippo","status":1,"leaf":true},
    {"id":3,"name":"Paperino","status":2,"leaf":true}],
"success":true
}

现在,谁能解释一下:

(1) 为什么,当我点击第一个节点的 [+] 图标时,应用程序会执行另一个 ajax 请求,而不是扩展从前一个请求中获得的内容

(2) 鉴于此初始观点:

为什么当我点击 [+] 时它开始像这样疯狂:

【问题讨论】:

    标签: extjs treepanel


    【解决方案1】:

    这显然是煎茶架构师的问题。

    我在一个新项目中从头开始重写了相同的架构,现在它可以按预期工作了。

    另外,我注意到 Architect 出了点问题,因为简单的操作使它显示出难以理解和无法调试的错误(例如“无法设置属性 'DirectCfg' of null”)。

    不幸的是,我不能说 Sencha Architect 对于大型和复杂的项目是成熟的......甚至对于小型项目来说可能都不是。可惜了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-27
      • 2017-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-09
      • 2013-07-07
      相关资源
      最近更新 更多