从数据视图拖动并在extjs4中放入面板

时间:2012-10-29 07:36:42

标签: extjs drag-and-drop extjs4

我正在创建拖放,其中我有一组带有一组图像的数据视图。然后我有一个面板,我想让用户从数据视图中删除图像。使用sencha示例中的示例,我能够得到类似的东西。但我收到了一个错误

Uncaught TypeError: Cannot set property 'afterValidDrop' of undefined 

这就是我在面板中的内容。

Ext.define('Memegen.view.MemeBuildArea',{
    extend: 'Ext.panel.Panel',
    alias: 'widget.memebuildarea',
    listeners: {
        render: initializeMemeDropZone
    },
    cls: 'meme-target',
});

function initializeMemeDropZone(targetPanel) {  
    targetPanel.dropTarget = Ext.create('Ext.dd.DropTarget', targetPanel.el);
    targetPanel.dropTarget.notifyDrop = function(source, evt, data) {
    if(typeof console != "undefined")
      console.log("notifyDrop:" + source.id);
    var droppedPanel = Ext.getCmp(source.id);

    droppedPanel.dd.afterValidDrop = function() {
      targetPanel.add(droppedPanel.cloneConfig({
        draggable: false,
        title: "Can't Drag This Panel."
      }));
      droppedPanel.destroy();
    };
    return true;
}

  targetPanel.dropTarget.notifyEnter = function(source, evt, data) {
    if(typeof console != "undefined")
      console.log("notifyEnter:" + source.id);
    return this.callParent(Array.prototype.slice.call(arguments));
  };

  targetPanel.dropTarget.notifyOut = function(source, evt, data) {
    if(typeof console != "undefined")
      console.log("notifyOut:" + source.id);
    return this.callParent(Array.prototype.slice.call(arguments));
  };

  targetPanel.dropTarget.notifyOver = function(source, evt, data) {
    if(typeof console != "undefined")
      console.log("notifyOver:" + source.id);
    return this.callParent(Array.prototype.slice.call(arguments));
  };

}

关于这里出了什么问题的任何想法?

1 个答案:

答案 0 :(得分:0)

为了定义dd属性,您的面板需要可拖动(请参阅Ext.panel.Panel的API文档,draggable config)。

相关问题