ExtJS4
我正在尝试将树节点移动到网格面板。我希望将其关联数据插入此处。但是每当我移动树节点时,它都会在该位置创建一个空行。我将树创建为:
var treeData = {
text: 'Business Processes',
children:[
{text: 'Process7', lob: 'Lob7', leaf:true},
{text: 'Process8', lob: 'Lob8', leaf:true},
{text: 'Process9', lob: 'Lob9', leaf:true},
{text: 'Process10', lob: 'Lob10', leaf:true},
{text: 'Process11', lob: 'Lob11', leaf:true},
{text: 'Process12', lob: 'Lob12', leaf:true}
]
};
bpTreeStore = Ext.create('Ext.data.TreeStore',{});
bpTreeStore.setRootNode(treeData);
new Ext.TreePanel({
id:'businessProcessTree',
store : bpTreeStore,
viewConfig: {
plugins:{
ptype: 'treeviewdragdrop',
dropGroup: 'dragGroup',
dragGroup: 'dragGroup',
dragText: 'Place the node to grid'
}
}
});
和网格一样
Ext.define('BusinessProcessStoreModel',{
extend:'Ext.data.Model',
fields: [
{ name:'businessProcessName', type:'string' },
{ name:'businessProcessLob', type:'string' }
]
});
bpMappingStore = Ext.create('Ext.data.ArrayStore', {
model:'BusinessProcessStoreModel',
data:[
['Process1', 'Lob1'],
['Process2', 'Lob2'],
['Process3', 'Lob3']
]
});
var bpMappingGrid = Ext.create('Ext.grid.Panel',{
id:'bpGridPanel',
region:'center',
frame:true,
layout:'fit',
height:300,
columns:[
{ header:'Process Name', dataIndex:'businessProcessName' },
{ header:'Process Lob', dataIndex:'businessProcessLob' }
],
store:bpMappingStore,
viewConfig: {
plugins:{
ptype: 'gridviewdragdrop',
dropGroup: 'dragGroup',
dragGroup: 'dragGroup',
dragText: 'Place the node to grid'
},
listeners: {
drop: function(node, data, overModel, dropPosition)
{
var position = (dropPosition=='after'?overModel.index + 1: overModel.index -1);
Ext.getCmp('bpGridPanel').store.insert(position, [[data.records[0].data.text, 'LOB']]);
//data.records[0].data.lob is undefined don't know why
}
}
}
});
请告诉我如何引用要插入到网格面板的两列中的树节点的“文本”和“lob”。
在这里我创建了我自己的