如何限制拖动操作不超过某一边界。在extjs (版本3)中有没有配置,我看到了,用的是Ext.dd.DragZone类。但我不确定什么是可用性。我看到了一个方法dropNotAllowed。这就是必须要使用的方法吗?如果是这样,我应该如何使用它?请提供一些示例。
我正在寻找类似于(jquery UI的draggable containment属性)的东西
http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.dd.DragZone-cfg-dropNotAllowed
我尝试使用设置X和Y约束,但不起作用:
abc.prototype.initDrag = function(v) {
    v.dragZoneobj = new Ext.dd.DragZone(v.getEl(), {
                getDragData : function(e) {
                    var sourceEl = e.getTarget(v.itemSelector, 10);
//                    sourceEl.setXConstraint( 0, 10 );
                    var t = e.getTarget();
                    var rowIndex = abc.grid.getView().findRowIndex(t);
                    var columnIndex = abc.grid.getView().findCellIndex(t);
                    if ((rowIndex !== false) && (columnIndex !== false)) {
                        if (sourceEl) {
                            abc.isDragged = true;
                            abc.scriptGrid.isDraggableForObject = false;
                            abc.scriptGrid.dragRowIndex = false;
                            d = sourceEl.cloneNode(true);
                            d.id = Ext.id();
                            d.textContent = sourceEl.innerHTML;
//                            d.setXConstraint( 0, 10 );
//                            d.setYConstraint( 0, 10 );
                            return {
                                ddel : d,
                                sourceEl : d,
                                sourceStore : v.store
                            }
                        }
                    }   
                },
                getRepairXY : function() {
                    return this.dragData.repairXY;
                },          
            });
}这两个都在上面的代码中被注释。上面的代码是在呈现面板时启动的。
编辑:如何使用这些setX和setYcontraints?
发布于 2016-06-17 15:26:25
默认情况下,可以将元素拖动到屏幕上的任何位置。文档中有两个方法setXConstraint( iLeft, iRight, iTickSize)和setYConstraint( iUp, iDown, iTickSize ),这两个方法用于设置限制元素的垂直移动和水平移动。
https://stackoverflow.com/questions/37859712
复制相似问题