1. #1
    Sencha User
    Join Date
    Mar 2009
    Posts
    41
    Vote Rating
    0
    cgokey2 is on a distinguished road

      0  

    Default [1.2.3] Tree Drag & Drop not updating model when drop occurs in TreeDropTarget

    [1.2.3] Tree Drag & Drop not updating model when drop occurs in TreeDropTarget


    Please take a look at the test case below. It should run.

    There are 3 nodes in this tree (X,Y,Z). If you drag X into Y,
    then X becomes a child of Y. Then try dragging Y into Z. When
    this occurs, you lose X as a child of Y.


    See problem code code that sets up the issue of inserting X,Y,Z nodes described above.

    Code:
    package gov.nasa.gsfc.gcmd.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.extjs.gxt.ui.client.widget.Window;
    import com.extjs.gxt.ui.client.widget.ContentPanel;
    import com.extjs.gxt.ui.client.widget.tree.Tree;
    import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
    import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
    import com.extjs.gxt.ui.client.widget.grid.Grid;
    import com.extjs.gxt.ui.client.widget.layout.FitLayout;
    import com.extjs.gxt.ui.client.store.ListStore;
    import com.extjs.gxt.ui.client.store.TreeStore;
    import com.extjs.gxt.ui.client.data.BaseModel;
    import com.extjs.gxt.ui.client.data.BaseTreeModel;
    import com.extjs.gxt.ui.client.binder.TreeBinder;
    import com.extjs.gxt.ui.client.dnd.TreeDragSource;
    import com.extjs.gxt.ui.client.dnd.DND;
    import com.extjs.gxt.ui.client.dnd.TreeDropTarget;
    
    import java.util.List;
    import java.util.ArrayList;
    import java.io.Serializable;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class Test implements EntryPoint
    {
        public void onModuleLoad() {
            RootPanel.get().add(createTreeTest());
        }
    
        public ContentPanel createTreeTest() {
            ContentPanel w = new ContentPanel();
    
            final Tree tree = new Tree();
    
            final Node root = new Node("Root");
            Node x = new Node("X");
            Node y = new Node("Y");
            Node z = new Node("Z");
            x.add(new Node("1"));
            y.add(new Node("2"));
            z.add(new Node("3"));
    
            root.add(x);
            root.add(y);
            root.add(z);
    
            tree.getStyle().setLeafIconStyle("icon-keyword");
    
            final TreeStore store = new TreeStore();
            final TreeBinder binder = new TreeBinder(tree, store);
            binder.setAutoLoad(true);
            binder.setDisplayProperty("name");
            binder.init();
    
            TreeDragSource source = new TreeDragSource(binder);
            TreeDropTarget target = new TreeDropTarget(binder);
            target.setAllowSelfAsSource(true);
            target.setFeedback(DND.Feedback.APPEND);
    
    
            store.add(root, true);
            tree.getRootItem().getItem(0).setExpanded(true);
    
            w.add(tree);
    
            return w;
        }
    
      
    class Node extends BaseTreeModel implements Serializable {
        public Node() {
        }
    
        public Node(String name) {
            set("name", name);
        }
    
        public String getName() {
            return (String) get("name");
        }
    
        public String toString() {
            return getName();
        }
    
    }
    Changing TreeDropTarget seems to fix my case...

    Code:
    protected void handleAppendDrop(DNDEvent event, TreeItem item) {
            List sel = (List) event.data;
            if (sel.size() > 0) {
                if (sel.get(0) instanceof ModelData) {
                    ModelData p = item.getModel();
                    binder.getTreeStore().add(p, sel, true);
                    -----------> ((TreeModel)p).add((TreeModel)sel.get(0));
                } else {
                    for (int i = 0; i < sel.size(); i++) {
                        TreeItem ti = (TreeItem) sel.get(i);
                        item.add(ti);
                    }
                }
            }
    
        }
    Is this the correct solution? Also, I'm finding myself in my own code having to duplicate adding child nodes to a tree by updating both model and the store (one for the store, one for the model). Is there a way to only work with the model and the store will automatically update?



    Thanks,
    Chris

  2. #2
    Sencha User
    Join Date
    Mar 2009
    Posts
    41
    Vote Rating
    0
    cgokey2 is on a distinguished road

      0  

    Default


    Same bug can be found in your demo code:
    http://extjs.com/examples/dnd/reorderingtree.html

    Try dragging Grids folder into the Tabs folder...
    Then drag Tabs folder into the Windows folder...
    You lose the Grids folder (which should be in Tabs)

    Chris

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi