Hug*_*ugh 8 drag-and-drop extjs extjs3
我想构建一个ExtJS FormPanel,允许用户使用拖放重新排序字段集列表.
我看到通过使用draggable使得字段集可以移动非常容易:true,但是如何设置dropzone?我试图效仿一些例子,但运气不好.
MyApp.FormPanel = Ext.extend(Ext.FormPanel,{
title: 'Fields',
fieldSetCount: 0,
constructor: function(config){
Ext.apply(this, config);
this.tbar = [{
text: 'Add Field Set',
handler: this.addFieldSet,
scope: this
}];
MyApp.FormPanel.superclass.constructor.call(this, config);
},
addFieldSet: function(){
this.add({
xtype: 'fieldset',
title: 'Fieldset ' + this.fieldSetCount++,
draggable: true
});
this.doLayout();
},
});
Run Code Online (Sandbox Code Playgroud)
您需要实现 Ext.dd.DropZone 来存档!有关详细信息,请参阅Ext.JS 3.x API
以下示例未经测试,但它应该向您展示技巧!
FormDropZone = function (form, config) {
this.form = form;
FormDropZone.superclass.constructor.call(this, form.view.scroller.dom, config);
};
Ext.extend(FormDropZone, Ext.dd.DropZone, {
onContainerOver: function (dd, e, data) {
return dd.form !== this.form ? this.dropAllowed : this.dropNotAllowed;
},
onContainerDrop: function (dd, e, data) {
if (dd.form !== this.form) {
this.form.onFormDrop(this.form, data.selections, dd.form);
return true;
}
else {
return false;
}
},
containerScroll: true
});
DDform = Ext.extend(Ext.form.formPanel, {
// configuration
initComponent: function () {
var config = {};
Ext.apply(this, Ext.apply(this.initialConfig, config));
DDform.superclass.initComponent.apply(this, arguments);
},
onRender: function () {
DDform.superclass.onRender.apply(this, arguments);
this.dz = new FormDropZone(this, { ddGroup: this.ddGroup || 'formDD' });
},
onFormDrop: Ext.emptyFn
});
Run Code Online (Sandbox Code Playgroud)
希望这对您有帮助!
| 归档时间: |
|
| 查看次数: |
2243 次 |
| 最近记录: |