extJs 中,tree向grid 拖动或者tree向另一个Tree拖动

源树中当然正常写,但要在treepanel设置两个属性
enableDrag : true,
ddGroup : 'jldTreeDragDrop', 这个名字重要,以后要一样。

下面是grid的处理
this.gridSmX=new Ext.grid.CheckboxSelectionModel({
singleSelect : true
});
this.cm = new Ext.grid.ColumnModel([
{header:'资源内部编码', sortable: true, dataIndex:'id',width:83},
{header:'资源名称', sortable: true, dataIndex:'name',width:90},
{header:'源系统名称', sortable: true, dataIndex:'sourceName',width:85},
{header:'源系统资源标识', sortable: true, dataIndex:'sourceId',width:100},
{header:'源系统资源名称', sortable: true, dataIndex:'sour_Psr_Name',width:100},
{header:'源系统资源编码', sortable: true, dataIndex:'sourcePsrNo',width:100},
{header:'运算符号',hidden:true,dataIndex:'symbol',width:90,renderer: this.formatSymbol,
editor:new Ext.form.ComboBox({
valueField:'ivalue',
displayField:'dvalue',
mode: 'local',
triggerAction : 'all',
store: new Ext.data.ArrayStore({
fields: ['ivalue', 'dvalue'],
data:[
['1', '加法(+)'],
['-1', '减法(-)']
]
})
})
},
{header:'系数',hidden:true,dataIndex:'factor',width:50,
editor: new Ext.form.NumberField({
allowBlank: false,
allowNegative: true,
maxLength: 13,
decimalPrecision:6,
maxValue: 999999.999999
}),width:80
},
{header:'取绝对值',hidden:true,dataIndex:'abs',renderer: this.formatABS,
editor: new Ext.form.Checkbox(),width:75
},
{header:'操作', dataIndex:'oper',renderer:this.gridDeleteButton,width:75}
]);
this.ds = new Ext.data.JsonStore({
url:this.queryRelationUrl ,
fields: [
{name: 'id',mapping: 'psrid',type:'string'},
{name: 'name',mapping: 'psrName',type:'string'},
{name: 'sourceName',mapping: 'sourceSysName',type:'string'},
{name: 'sourceId',mapping: 'sourcePsrId',type:'string'},
{name: 'sour_Psr_Name',mapping: 'sourcePsrName',type:'string'},
{name: 'sourcePsrNo',mapping: 'sourcePsrNo',type:'string'},
{name: 'oper'},
{name: 'symbol',mapping:'symbol',type:'int'},
{name: 'factor',mapping:'factor',type:'double'},
{name: 'abs',mapping:'abs', type: 'bool'},
{name: 'sourceSysId',mapping: 'sourceSysId',type:'string'},
{name: 'psrTypeCode',mapping: 'psrTypeCode',type:'string'}
]
});
this.gridRela = new Ext.grid.EditorGridPanel({
region: 'center',
split: true,
cm: this.cm,
ds: this.ds,
sm: this.gridSmX,
loadMask:true,
autoScroll: 'true',
ddGroup : 'jldTreeDragDrop',
isTarget : true,
autoExpandColumn: 6,
stripeRows: true,
clicksToEdit: 1,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
listeners : {
render : function (g){
var secondGridDropTargetEl = this.getView().el.dom.childNodes[0].childNodes[1];
var destGridDropTarget = new Ext.dd.DropTarget(secondGridDropTargetEl,
{
ddGroup : 'jldTreeDragDrop',
copy : false,
notifyDrop : function(ddSource, e, data){
if(!proxyRelation.isQueryPsr){
disAlertInfo("请先选择左边的资源树里你要设置对应关系的资源!");
return ;
}
var sourceNode = ddSource.dragData.node;
if(sourceNode.attributes.isPsr=='false'){
disAlertInfo('不能对源系统资源类型设置对应关系');
return ;
}
var sourceParam=sourceNode.id.split("_");
proxyRelation.sourcePsrTypeId=sourceParam[0];
proxyRelation.sourcePsrId=sourceParam[1];

//调用方法统一处理拖动至树或者拖动至网格事件
proxyRelation.checkPsrRelationAndSave(proxyRelation.psrId,proxyRelation.psrTypeId,proxyRelation.sourceSys,proxyRelation.sourcePsrId,proxyRelation.sourcePsrTypeId,false);
}
});
}
}
});
//编辑表格
this.gridRela.on('afteredit',function(e){
var record = e.record;// 被编辑的记录

Ext.Ajax.request( {
url : proxyRelation.updateRelationUrl,
success: function(response, options) {
var json = Ext.decode(response.responseText);
if(!json){
disAlertInfo('更新对应关系失败,请检查书写数值');
//grid表格数据重新载入
proxyRelation.gridReloadFunction(proxyRelation.psrId,proxyRelation.psrTypeId);
}
},
params:{
'psrId' : record.data.id,
'psrTypeCode' : record.data.psrTypeCode,
'sourceSysId' : record.data.sourceSysId,
'sourcePsrId' : record.data.sourceId,
'symbol' : record.data.symbol,
'factor' : record.data.factor,
'abs' : record.data.abs
}
});
});
该grid有几个字段还要是可以编辑的,编辑后发到后台,所有用了EditGridpanel如果不需要编辑,用gridPanel也可以

下面是树的处理
this.tree = new Ext.tree.TreePanel({
split:true,
region:'west',
autoScroll:true,
animate:true,//开启动画效果
enableDrop: true,
width : 189,
minSize : 100,
maxSize : 500,
rootVisible:false,
dropConfig:{
ddGroup: 'jldTreeDragDrop',// 从Grid到Tree。如果是Tree内部节点拖动,使用'jldTreeDragDrop'
dropAllowed: true
},
loader: new Ext.tree.TreeLoader({
dataUrl:proxyRelation.psrTreeUrl
})
});
this.root = new Ext.tree.AsyncTreeNode({
text: '资源树',
expanded :true,
draggable:false,
id:'0'
});
this.tree.setRootNode(this.root);
//动态加载树的访问定义
this.tree.on('beforeload',function(node){
return proxyRelation.queryTreeParamsParse(node,proxyRelation.tree,proxyRelation.psrTreeUrl);
});
/**
* 处理树节点之间
*/
this.tree.on('beforenodedrop',function(e){
var sourceNode=e.source.dragData.node;
var targetNode=e.target;
if(sourceNode.attributes.isPsr=='false'){
disAlertInfo('源系统资源类型不能拖动');
return false;
}
if(targetNode.attributes.isPsr=='false'){
disAlertInfo('系统资源类型不能设置对应关系');
return false;
}
var par1=targetNode.id.split('_');
var TypeID=par1[0];
var psrID=par1[1];
var par2=sourceNode.id.split('_');
var sourceTypeID=par2[0];
var sourcePsrID=par2[1];
//调用方法统一处理拖动至树或者拖动至网格事件
return proxyRelation.checkPsrRelationAndSave(psrID,TypeID,proxyRelation.sourceSys,sourcePsrID,sourceTypeID,true);
});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值