PDA

View Full Version : Tree and MultiSelectionModel issue



Traktopel
15 Feb 2010, 10:37 AM
Hi all,

I try to simply remove 4 childs from a treeNode and set them in an other one ... but when I use MultiSelectionModel with more than one selection, I got an obscure error ('b is undefined')

Here is a sample :

var nodes = new Ext.tree.TreeNode({
id : 'root',
id: 'test',
text: 'test'
});
var node1 = new Ext.tree.TreeNode({
id : 'node1',
text: '1',
test: new Ext.form.FormPanel()
});
var node2 = new Ext.tree.TreeNode({
id : 'node2',
text: '2',
test: new Ext.form.FormPanel()
});
var node3 = new Ext.tree.TreeNode({
id : 'node3',
text: '3',
test: new Ext.form.FormPanel()
});
var node4 = new Ext.tree.TreeNode({
id : 'node4',
text: '4',
test: new Ext.form.FormPanel()
});
nodes.appendChild(node1);
nodes.appendChild(node2);
nodes.appendChild(node3);
nodes.appendChild(node4);

var tree1 = new Ext.tree.TreePanel({
id : 'tree',
animate: false,
autoScroll: true,
title: 'Title',
height: 300,
width: 150,
selModel: new Ext.tree.MultiSelectionModel({}),
enableDD: true,
rootVisible: false,
root: nodes,
loader: new Ext.tree.TreeLoader(),
dropConfig: {
allowContainerDrop: true
}
});

var button = new Ext.Button({
id: 'addbutton',
text : 'copy',
height: 32,
width: 32,
handler: function(){
var selModel = tree1.getSelectionModel();
var selection = selModel.getSelectedNodes();

if (selection.length > 0) {
var sourceRootNode = tree1.getRootNode();
Ext.each(selection, function(node){
//console.log(node);
sourceRootNode.removeChild(node);
});
}
}
});

var panel = new Ext.Panel({
layout: 'form',
items: [tree1, button],
renderTo: Ext.getBody()
});I cannot figure out why my 'selection' array is not correctly filled as soon as I remove a node from the rootnode ...

What mistake did I make ?
Thank you.