【问题标题】:Tree Panel 'nodeexpand' event in Extjs6.5 not workingExtjs 6.5中的Treepanel“节点扩展”事件不起作用
【发布时间】:2017-09-26 03:25:25
【问题描述】:

我正在尝试创建一个类似于文件夹资源管理器的 TreePanel。当我单击树面板中的节点扩展器(如下图所示)时,我试图找到该事件。

有谁知道正确的事件是什么?

这是我的观点的代码:

Ext.define('HDDTest.view.mod.searchDetails', {
    extend: 'Ext.Panel',
    xtype:'searchDetails',
    controller: 'home',
    requires: [
        'HDDTest.view.mod.PreviewPlugins.PreviewPlugin',
        'Ext.grid.*',
        'Ext.data.*',
        'Ext.util.*',
        'Ext.toolbar.Paging',
        'Ext.tip.QuickTipManager'
    ],
    items: [
        {
            xtype: 'treepanel',
            iconCls: 'icon-tree',
            title: 'Tree',
            collapsible: true,
            height: 300,
            padding:'0 20 0 0',
            rootVisible: false,
            id: 'treePanel',
            name:'treePanel',
            store: {
                type: 'TreeBufferStore'
            },
            listeners: {
                itemclick: 'onNodesSelected',
                nodeexpand  : 'onNodesSelected2' //<== It can not work
            },

            columns: [{
                xtype: 'treecolumn', //this is so we know which column will show the tree
                text: 'Representation',
                width: 360,
                sortable: true,
                dataIndex: 'text',
                locked: true
            }, {
                text: 'Parents',
                width: 430,
                dataIndex: 'From',
                sortable: true
            }, {
                text: 'NCID',
                width: 430,
                dataIndex: 'ncid',
                sortable: true

            }]
        }
    ]
});

我什么也得不到。我该怎么做?

【问题讨论】:

    标签: extjs


    【解决方案1】:

    使用 itemexpand 代替 nodeexpand 会起作用。

    我创建了一个演示,你可以在这里查看它是如何工作的 Sencha Fiddle

    希望它能帮助您解决问题。

    var store = Ext.create('Ext.data.TreeStore', {
        autoLoad: true,
        autoSync: false,
        root: {
           expanded: true
        },
        proxy: {
            type: 'ajax',
            url: 'veddocs.json',
            timeout: 300000,
            reader: {
                type: 'json',
                root: 'children'
            }
        }
    });
    
    Ext.create('Ext.tree.Panel', {
        title: 'Simple Tree',
        width: 200,
        height: 150,
        store: store,
        rootVisible: false,
        renderTo: Ext.getBody(),
        listeners: {
            itemexpand: function( node, eOpts){//Fires after this Panel has expanded.
               Ext.Msg.alert('Success',`Your node <b>${node.get('text')}</b>  is exapand`);
            }
        }
    });
    

    【讨论】:

    • 我终于找到了名为“beforeload”的正确事件。谢谢你的帮助,Njdhv。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-09
    • 2014-07-12
    相关资源
    最近更新 更多