Results 1 to 2 of 2

Thread: GXT 2.2.5 TreeStore DragNDrop activity not reflected in TreeStore

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Oct 2012
    Vote Rating

    Default GXT 2.2.5 TreeStore DragNDrop activity not reflected in TreeStore

    I have a simple DragNDrop editor to modify a tree to be persisted in my db. (Using GXT 2.2.5 can't upgrade) I have a TreePanel constructed with a TreeStore. The TreePanel is both a TreePanelDragSource and TreePanelDropTarget.
    The drag/drop works fine; As a test, I used the TreeStore from an existing, open Dialog window. As I drag/drop in the editor, the other window immediately shows the changes.

    However, when I fetch the TreeStore to save it as a flat tree in the database, the nodes are not rearranged in the Store. How do I get the reorganized tree structure?


  2. #2
    Sencha User
    Join Date
    Oct 2012
    Vote Rating

    Default My solution

    Apparently there is no way to directly get at the Tree structure altered by Drag and Drop.
    I reasoned that TreePanelView = TreePanel.getView() might have the Drag and Drop chaanges.
    By examining TreePanelView in the debugger after a drag and drop I devise this solution:
    * These 'My' classes are used to access the internal tree within TreePanelView.
    * The internal tree reflects Drag and Drop activity,
    * which is NOT reflected in the TreeStore.
    private class MyTreePanel<M extends ModelData> extends TreePanel<M> {
    public MyTreePanel(TreeStore<M> ts) {
    view = new MyView<M>();
    view.bind(this, store);
    public MyView<M> getMyView() {
    return (MyView<M>) getView();
    private class MyView<M extends ModelData> extends TreePanelView<M> {
    public MyTreeStore<M> getTreeStore() {
    return (MyTreeStore<M>) this.treeStore;
    private class MyTreeStore<M extends ModelData> extends TreeStore<M> {
    public MyTreeStore() {
    public Map<M, TreeModel> getModelMap() {
    return modelMap;
    To extract the tree altered by Drag and Drop:
    MyTreePanel<ModelData> myTree; //Initialize the TreeStore appropriately

    // After Drag and Drop activity, get the altered three thusly:
    Map<ModelData, TreeModel> viewMap =

    The TreeModel in viewMap is actually a BaseTreeModel.
    The ModelData are the objects I originally loaded into TreeStore.
    I had to:
    1 - Iterate over viewMap, extract the "id" for each BaseTreeModel and create a reverse map,
    indexed by the "id" and containing my ModelData objects.
    2 - Fetch the root BaseTreeModel node from viewMap using the root ModelData of my original tree,
    3 - Walk the BaseTreeModel tree.
    At each node, fetched my ModelData objects by "id" from the reverse map.

    In this way I reconstructed the tree altered by Drag and Drop, which I then persisted to my DB.
    Last edited by TonyDiPaola; 6 Nov 2012 at 7:18 AM. Reason: indent code examples

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts