PDA

View Full Version : [FIXED] Selected Tree Item not Shown as Selected After Reordering the Tree Item



nyklogistics
25 Jun 2009, 1:28 AM
Regarding to this demo (http://extjs.com/examples-dev/explorer.html#reorderingtree), the selected item is not shown as selected after reordering the tree item. Actually, by calling tree.getSelectionModel().getSelectedItem(), it returns non-null model.
(I have tested in firefox, chrome and IE8)

darrellmeyer
25 Jun 2009, 6:53 AM
The previously selected item was not cleared on remove. Fixed in RC1.

nyklogistics
25 Jun 2009, 10:35 PM
The moving item is unselected when I drop it down. Should I select the dropped item again? If so, how can I get the previous selected item since I got null when I call tree.getSelectionModel().getSelectedItem() in the dragDrop() method of TreePanelDragTarget DNDListener.

sven
26 Jun 2009, 2:14 AM
You could store the selection before startign the drag (for example in a listener) and restore it on a drop.

nyklogistics
26 Jun 2009, 2:36 AM
Yes, I can select in this way. But, visually, it is not selected. It remains white in color.
Below is my code:



TreePanelDragSource source = new TreePanelDragSource(menuTreePanel);
source.addDNDListener(new DNDListener() {

ModelData sel;

@Override
public void dragStart(DNDEvent e) {
sel = ((TreePanel) e.getComponent()).getSelectionModel()
.getSelectedItem();
if (sel != null
&& sel == ((TreePanel) e.getComponent()).getStore()
.getRootItems().get(0)) {
e.setCancelled(true);
e.getStatus().setStatus(false);
return;
}
super.dragStart(e);
}

@Override
public void dragDrop(DNDEvent e) {
((TreePanel) e.getComponent()).getSelectionModel().select(
false, sel);
super.dragDrop(e);
}

});

sven
26 Jun 2009, 2:42 AM
You have to to this after the dropping is done. Currently you select it before it.