【问题标题】:dgrid dnd implement onDrop eventdgrid dnd 实现 onDrop 事件
【发布时间】:2016-06-01 13:01:25
【问题描述】:

我想在 dgrid 中实现 DnD 的 drop 事件的自定义行为。我有以下 gdrig 声明:

this.grid = new (declare([OnDemandGrid, Editor, DnD, DijitRegistry]))({
                        region: "center",
                        collection: this.store,
                        selectionMode: 'single',
                        columns: ...
                    }, this.gridNode);

                    this.grid.startup();

我真正想要的很简单:在网格中拖放一行(重新排序 dgrid 中的项目)后,我想触发一个事件(函数 - 比如说获取当前行并对其进行操作等)。 问题是我不知道如何覆盖 onDrop 事件或拖动事件。谁能给我一个提示。

【问题讨论】:

    标签: javascript dojo dgrid dojo-dnd


    【解决方案1】:

    有一种简单的机制可以替换 onDrop,但是如何保留和扩展现有的 onDrop 功能完全不明显。这是因为 onDrop 存在于网格创建的名为DnDSource 的类中。幸运的是,这是一个dependency that can be injected(通过一个名为 dndConstructor 的属性)。这是我的解决方案:

    var MyDnDSource = declare([DnDSource], {
        onDrop: function() {
            this.inherited(arguments); // This is the original onDrop functionality
            console.log('This is my additional onDrop functionality');        
      }
    });
    
    this.grid = new (declare([OnDemandGrid, Editor, DnD, DijitRegistry]))({
                        dndConstructor: MyDnDSource,
                        region: "center",
                        collection: this.store,
                        selectionMode: 'single',
                        columns: ...
                    }, this.gridNode);
    
    this.grid.startup();
    

    【讨论】:

      猜你喜欢
      • 2013-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-10
      • 1970-01-01
      • 2023-02-01
      • 2018-09-17
      • 1970-01-01
      相关资源
      最近更新 更多