PDA

View Full Version : TreePanel node remove BUG?



amsoft
25 May 2012, 3:29 AM
Hi,

Here is the code which removes a node from the tree panel.


var nodeToDelete = tree.getSelectionModel().getLastSelected();
var nodeToDeleteInterface = tree.getNodeById(nodeToDelete.get('id'));
nodeToDelete.remove(true);
// nodeToDeleteInterface.remove(); //either of these 2 works
console.log (tree.getSelectionModel().hasSelection()); // true
console.dir(tree.getSelectionModel().getSelection()); // shows nodeToDelete

Node is removed, selection is visually cleaned but, in fact, selection model still stores reference for this node. So I have to call selModel.deselectAll().
Is it bug or I do something wrong?

Thanks.

redraid
25 May 2012, 4:44 AM
Looks like bug, workaround:


var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "detention", leaf: true },
{ text: "homework", expanded: true, children: [
{ text: "book report", leaf: true },
{ text: "alegrbra", leaf: true}
] },
{ text: "buy lottery tickets", leaf: true }
]
}
});

Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
renderTo: Ext.getBody(),
multiSelect: true,
tbar: [{
text: 'remove',
handler: function (btn) {
var tree = btn.up('treepanel'),
nodes = tree.view.getSelectedNodes(),
record;

console.log('selected', nodes);
nodes = Ext.Array.filter(nodes, function (n) {
return !Ext.isEmpty(n);
});
console.log('cleaned selected', nodes);

if (nodes.length === 0) {
return;
}

record = tree.view.getRecord(nodes[nodes.length-1]);

if (record) {
record.remove(true);
}
}
}]
});

Console, after second remove:
selected [


<tr class=?"x-grid-row x-grid-tree-node-leaf x-grid-row-selected" id=?"ext-gen1039">??</tr>?
, null]
cleaned selected [

<tr class=?"x-grid-row x-grid-tree-node-leaf x-grid-row-selected" id=?"ext-gen1039">??</tr>?
]

amsoft
20 Jun 2012, 3:11 AM
Any new here? Can it be moved to bugs?