更新9/11/13 - 下面是一個完全正常的jsFiddle演示問題...體驗問題,展開網格並嘗試將嵌套行拖到TreePanel。 drag元素將被TreePanel模糊處理,就好像它在後面一樣。鏈接在這裏:http://jsfiddle.net/ZGxf5/ExtJS 4.1 - 使用RowExpander拖放問題
這裏有點獨特的路障我碰到的......我想它會用圖像來最好的說明:
正如你可以在圖片中看到,我試圖拖動div
,通過在圖像的左下角所示的網格中使用的RowExpander
插件的rowBodyTpl
屬性生成。我能夠「抓住」元素並將其移動,但它似乎受限於RowExpander生成的div。我不能拖動任何更離開的div,也不能從原來的位置向上拖動div。試圖將其移動到面板右側會導致拖動div被模糊處理,如圖所示。
我試圖完全消除startDrag
方法的所有約束,你將在下面的代碼中看到,但都無濟於事。我基本上只是使用Sencha的5 Steps to Understanding Drag and Drop with ExtJS Blog Post中提供的代碼,但顯然需要對我的實現進行一些調整。
下面是我對初始化目標DIV拖動代碼..如下
/**
* NOTE: The following code is executed whenever
* the contents of the grid's store change
*/
var me = this, // ENTIRE left panel, including the TreePanel and lower GridPanel
divs = Ext.select('div[name=storage-item-div]', false, me.getEl().dom),
dragOverrides = {}; // provided separately, see below
Ext.each(divs.elements, function(el){
console.warn("mkaing new dd", el);
var dd = new Ext.dd.DD(el, 'storageItemDDGroup',{
isTarget: false
});
Ext.apply(dd, dragOverrides);
});
的dragOverrides
對象被定義(注意我的約束調試)
dragOverrides = {
b4StartDrag : function() {
// Cache the drag element
if (!this.el) {
this.el = Ext.get(this.getEl());
}
//Cache the original XY Coordinates of the element, we'll use this later.
this.originalXY = this.el.getXY();
},
startDrag: function(){
/** DEBUGGING */
_t = this;
this.resetConstraints();
this.setXConstraint(1000,1000);
this.setYConstraint(1000,1000);
},
// Called when element is dropped not anything other than a dropzone with the same ddgroup
onInvalidDrop : function() {
// Set a flag to invoke the animated repair
this.invalidDrop = true;
},
// Called when the drag operation completes
endDrag : function() {
// Invoke the animation if the invalidDrop flag is set to true
if (this.invalidDrop === true) {
// Remove the drop invitation
this.el.removeCls('dropOK');
// Create the animation configuration object
var animCfgObj = {
easing : 'elasticOut',
duration : 1,
scope : this,
callback : function() {
// Remove the position attribute
this.el.dom.style.position = '';
}
};
// Apply the repair animation
this.el.moveTo(this.originalXY[0], this.originalXY[1], animCfgObj);
delete this.invalidDrop;
}
}
最後,我想下層網格配置的rowBodyTpl
部分可能對解決這個問題很有用,所以這裏是源代碼!
rowBodyTpl : ['<div id="OrderData-{item_id}" style="margin-left: 50px;">'+
'<tpl for="order_data">'+
'<tpl for=".">' +
'<div name="storage-item-div" class="draggable" style="padding-bottom: 5px;">' +
'<b>{quantity}</b> from Purchase Order <b>{purchase_order_num}</b> @ ${purchase_cost}' +
'<input type="button" style="margin-left: 10px;" name="storageViewOrderButton" orderid="{purchase_order_id}" value="View Order"/>' +
'</div>' +
'</tpl>' +
'</tpl>'+
'</div>']
新增jsFiddle示例:http://jsfiddle.net/ZGxf5/ –