Results 1 to 2 of 2

Thread: BaseTreeModel - setParent - suggest

  1. #1
    Ext User fother's Avatar
    Join Date
    Sep 2007
    Location
    Brazil
    Posts
    744

    Default BaseTreeModel - setParent - suggest

    actually in gxt if you set parent dont added the son at the parent..

    code example..
    Code:
    		final BaseTreeModel father = new BaseTreeModel();
    		final BaseTreeModel son = new BaseTreeModel();
    		son.setParent(father);
    
    		System.out.println(father.getChildren());
    always will return a empty list...

    my suggest is that if the model have the parent automatic should be have the son..
    code example
    Code:
    		final BaseTreeModel father = new BaseTreeModel();
    		final BaseTreeModel son = new BaseTreeModel() {
    			@Override
    			public void setParent(final TreeModel parent) {
    
    				super.setParent(parent);
    
    				parent.getChildren().add(this);
    			}
    		};
    		son.setParent(father);
    
    		System.out.println(father.getChildren());
    will return the childrens...

  2. #2
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961

    Default

    but there are other problem if you set the parent:

    1) moving item

    what is if this child is already attached to an other parent?
    then is should be removing this child from the old one.
    maybe a adopt before the children.add is better?

    2)
    and what if the items are connected to a tree? then the tee should informed via a change event

    3) setParent is also used internaly by BaseTreeModel. so if you overwrite it, then can be more problems with your solution for example adding it twice if you insert a children via BaseTreeModel#add(ModelData child)
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts Search Results Advanced Search form Category overview http://www.extjs.com/forum/showthrea...041#post410041

Posting Permissions

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