Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext GWT Premium Member
    Join Date
    Jun 2008
    Posts
    221
    Vote Rating
    0
    nyklogistics is on a distinguished road

      0  

    Default [CLOSED] Reordered Sequence Cannot be Retrieved in TreePanel

    [CLOSED] Reordered Sequence Cannot be Retrieved in TreePanel


    I have add a test button in your example.
    After reordering the items, I cannot retrieve the reordered sequence of the tree items.

    Code:
    public class ReorderingTreePanelDNDExample extends LayoutContainer {
    
      @Override
      protected void onRender(Element parent, int index) {
        super.onRender(parent, index);
        setLayout(new FlowLayout(10));
    
        LayoutContainer container = new LayoutContainer();
        container.setSize(280, 400);
        container.setBorders(true);
        container.setScrollMode(Scroll.AUTO);
    
        TreeStore<ModelData> store = new TreeStore<ModelData>();
        final TreeModel root = (ExamplesModel) Registry.get(Examples.MODEL);
        root.set("name", "Ext GWT");
        store.add(root, true);
    
        final TreePanel<ModelData> tree = new TreePanel<ModelData>(store) {
          @Override
          public boolean hasChildren(ModelData parent) {
            if ("My Files".equals(parent.get("name")) || parent instanceof Category) {
              return true;
            }
            return super.hasChildren(parent);
          }
        };
    
        tree.getStyle().setLeafIcon(IconHelper.createStyle("icon-list"));
        tree.setAutoLoad(true);
        tree.setDisplayProperty("name");
        tree.addListener(Events.Render, new Listener<TreePanelEvent<ModelData>>() {
          public void handleEvent(TreePanelEvent<ModelData> be) {
            be.getTreePanel().setExpanded(root, true);
          }
        });
    
        TreePanelDragSource source = new TreePanelDragSource(tree);
        source.addDNDListener(new DNDListener() {
          @Override
          public void dragStart(DNDEvent e) {
            ModelData sel = tree.getSelectionModel().getSelectedItem();
            if (sel != null && sel == tree.getStore().getRootItems().get(0)) {
              e.setCancelled(true);
              e.getStatus().setStatus(false);
              return;
            }
            super.dragStart(e);
          }
        });
    
        TreePanelDropTarget target = new TreePanelDropTarget(tree);
        target.setAllowSelfAsSource(true);
        target.setFeedback(Feedback.BOTH);
    
        container.add(tree);
        container.add(new Button("Test", new SelectionListener<ButtonEvent>() {
    
          @Override
          public void componentSelected(ButtonEvent ce) {
            List<ModelData> rootItems = tree.getStore().getRootItems();
            TreeModel root  = (TreeModel) rootItems.get(0);
            for (ModelData child : root.getChildren()) {
              Window.alert("child.name="+child.get("name"));
            }
          }
    
        }));
        add(container);
      }
    }

  2. #2
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    The parent / child relationships are not determined from the models itself, rather the store keeps the relationships internally. You must get a model's children from the tree store using store.getChildren(parent).

Thread Participants: 1