PDA

View Full Version : TreeTable Reordering Bug



jbotiva
7 May 2009, 3:03 PM
I have a TreeTable with SelectionMode.MULTI, when two or more items are selected and dragged, the items are allowed to be dropped in the dragged items except for the last selected item, this makes the dragged items disappear. The selected items belongs to the same TreeTableItem parent.

sven
8 May 2009, 4:08 PM
You really need to supply some code. Please see this thread on how to report a bug: http://www.extjs.com/forum/showthread.php?t=40289

jbotiva
11 May 2009, 6:30 AM
I'm using GXT 2.0 built on April 24th 2009

I've tested it in hosted and web mode on IE8 and Firefox 3.0.10 on Windows XP Pro SP3



TreeTable treeTable = new TreeTable();
treeTable.setAnimate(false);
treeTable.setSelectionMode(SelectionMode.MULTI);

treeTable.addListener(Events.BeforeCollapse, new Listener<TreeEvent>() {
public void handleEvent(TreeEvent te) {
if (te.getItem().getParentItem() == treeTable.getRootItem()) {
te.setCancelled(true);
}
}
});

MemoryProxy<List<BaseModelData>> memoryProxy = new MemoryProxy<List<BaseModelData>>(null) {
@Override
public void load(DataReader<List<BaseModelData>> reader, Object loadConfig, AsyncCallback<List<BaseModelData>> callback) {
try {
List<BaseModelData> children = new ArrayList<BaseModelData>();

...

callback.onSuccess(children);
} catch (Exception e) {
callback.onFailure(e);
}
}
};

treeTableLoader = new BaseTreeLoader<BaseModelData>(memoryProxy);

treeTableStore = new TreeStore<BaseModelData>(treeTableLoader);
treeTableStore.setStoreSorter(new StoreSorter<BaseModelData>() {
@Override
public int compare(Store<BaseModelData> store, BaseModelData m1, BaseModelData m2, String property) {

...

return super.compare(store, m1, m2, property);
}
});

final TreeTableBinder<BaseModelData> treeTableBinder = new TreeTableBinder<BaseModelData>(treeTable, treeTableStore);
treeTableBinder.setDisplayProperty("name");


TreeDragSource treeTableDragSource = new TreeDragSource((TreeTableBinder) treeTableBinder);
treeTableDragSource.addDNDListener(new DNDListener() {
@Override
public void dragStart(DNDEvent dnde) {
TreeItem item = treeTable.findItem(dnde.getTarget());
if (item != null && item == treeTable.getRootItem().getItem(0) && treeTable.getRootItem().getItemCount() == 1) {
dnde.setCancelled(false);
dnde.getStatus().setStatus(false);
return;
}
}
});

TreeDropTarget treeTableDropTarget = new TreeDropTarget((TreeTableBinder) treeTableBinder);
treeTableDropTarget.setAllowSelfAsSource(true);
treeTableDropTarget.setOperation(Operation.MOVE);
treeTableDropTarget.setFeedback(Feedback.INSERT);