drag-and-drop - 在 ExtJS 4 的树面板中创建拖放功能时,“this.el 为空”

标签 drag-and-drop extjs4 treepanel

我正在尝试在 ExtJS 4 的 treepanel 中实现拖放功能。基本上我想将一些节点从 Treepanel 拖到文本框中。我对 ExtJS 4 中实现拖放的方式感到非常困惑,但我也尝试编写一些代码。不知道正确与否。

我的代码如下:

CustomChart.js 文件内容

Ext.define('dd.view.CustomChart', {
    extend : 'Ext.panel.Panel',
    alias : 'widget.customChart',
    layout : {
        type : 'vbox',
        align : 'stretch'
    },

    initComponent : function() {
        this.items = [
            {
                xtype : 'textfield',
                name : 'values',
                fieldLabel : 'Drop values here'
            }
        ];
        this.callParent(arguments);
    }
});

我在 AttritionViewer 文件中使用这个 CustomChart 面板,如下所示:

Ext.define('dd.view.AttritionViewer', {
    extend : 'Ext.panel.Panel',
    alias : 'widget.attritionViewer',
    title : 'View attrition by dimensions',

    layout : 'border',

    initComponent : function() {
        this.items = [
            {
                xtype : 'treepanel',
                title : 'Select dimensions',
                store : 'Dimensions',
                rootVisible : false,
                region : 'west',
                height : '100%',
                width : '20%',
                viewConfig : {
                    plugins : {
                        ptype : 'treeviewdragdrop',
                        ddGroup: 'GridExample'
                    }
                }
            },
            {
                xtype : 'panel',
                region : 'center',
                    layout : {
                    type : 'vbox',
                    align : 'stretch'
                },
                items : [
                    {
                        xtype : 'customChart',
                        flex : 1
                    }
                ]
            }
        ];
        this.callParent(arguments);
    }
});

正如您在上面的代码中看到的,我为树面板设置了ViewConfigddGroup。现在我不确定将以下代码放在哪里,因此我将其放在 Controller 的 init() 方法中。我的 Controller 的 init() 方法如下所示:

var customChartEl =  Ext.widget('customChart');

var formPanelDropTarget = Ext.create('Ext.dd.DropTarget', customChartEl, {
    ddGroup: 'GridExample',

    notifyEnter: function(ddSource, e, data) {
        console.log('inside notifyEnter() method');
        //Add some flare to invite drop.
    /*    formPanel.body.stopAnimation();
        formPanel.body.highlight(); */
    },
    notifyDrop  : function(ddSource, e, data){
        console.log('inside notifyDrop() method');
        return true;
    }        
});

在此代码之后,我在 ext-debug.js(第 7859 行)处收到 this.el is null 错误。我不知道下一步该做什么。

请指导我如何将节点从树面板拖动到文本字段内。

提前致谢!!!

最佳答案

检查此链接, http://examples.extjs.eu/?ex=tree2divdrag 我也在尝试一项类似的任务。如果我得到一些输出,我可以帮助你。 如果你解决了你的问题,只需在这里做个笔记,这对我也有帮助。

也请检查此示例的来源。 http://docs.sencha.com/ext-js/4-0/#!/example/dd/dragdropzones.html

最美好的祝愿。

关于drag-and-drop - 在 ExtJS 4 的树面板中创建拖放功能时,“this.el 为空”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10472640/

相关文章:

extjs4.1 - 未捕获的类型错误 : Cannot read property 'internalId' of undefined( WHILE SORTING NODES ON EXPAND)

reactjs - 如何实现react-dnd useDragLayer?

jquery - 如何显示在html5中拖动内容时显示的标签?

extjs - 如何在 Accordion 布局中查询当前展开的项目

javascript - Extjs 4 - 为树面板创建模型

javascript - 从保存在全局常量中的 xmlDocument 创建 Extjs 树面板

javascript - 使用 javascript(或 css,如果可能的话更好)通过鼠标(或在移动设备中触摸)更改元素的大小,而不考虑 jquery ui

wpf - 即使列表框有项目,ListBox ItemContainerGenerator 也会返回 null

extjs4 - 在 ext.grid.panel 的 'tools' 配置选项中显示自定义图像

javascript - 使用 JavaScript 进行乘法