Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: [FIXED] setIconProvider(ModelStringProvider) on TreeBinder not working on roots

  1. #1
    Sencha User
    Join Date
    May 2008
    Location
    Germany
    Posts
    59

    Default [FIXED] setIconProvider(ModelStringProvider) on TreeBinder not working on roots

    The ModelStringProvider (aka IconProvider) seems to be consulted correctly for all tree elements but the root-elements.
    Firebug's Inspect Element tells me that the <div/> element's class for the icon is always "".
    This happens even if my ModelStringProvider always returns a certain String.

    Is this a known/fixed bug or shall I provide a snippet?

  2. #2
    Sencha User
    Join Date
    May 2008
    Location
    Germany
    Posts
    59

    Default

    setStyleProvider on TreeBinder does not seem to have any effect at all...

  3. #3
    Sencha User darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242

    Default

    I am not seeing any problems. Please post some simple test code that demonstrates the problem you are seeing.

  4. #4

    Default

    I have same bug !

  5. #5
    Sencha User darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242

    Default

    Please post some sample code.

  6. #6
    Sencha User
    Join Date
    May 2008
    Location
    Germany
    Posts
    59

    Default

    Ok, the code is quite long but I will use it to show several issues.

    I use the last official Beta3 release and the images and ext-all.css from the provided Explorer Demo of this Beta3 release.

    The code has been tested with Firefox, IE and hosted mode. Issues apply on all three.

    Code:
    public void onModuleLoad() {
            Viewport vp = new Viewport();
            final ContentPanel panel = new ContentPanel();
            
            final Tree tree = new Tree();
            tree.setCheckable(true);
            
            final TreeStore store = new TreeStore();
            final BaseTreeModel a = new BaseTreeModel();
            a.set("name", "Item 1");
            final BaseTreeModel b = new BaseTreeModel();
            b.set("name", "Item 2");
            final BaseTreeModel b1 = new BaseTreeModel();
            b1.set("name", "Item 21");
            final BaseTreeModel c = new BaseTreeModel();
            c.set("name", "Item 3");
            store.add(a);
            store.add(b);
            store.add(b, b1);
            store.add(c);
            
            final TreeBinder binder = new TreeBinder(tree, store);
            binder.setDisplayProperty("name");
            
            binder.setIconProvider(new ModelStringProvider() {
                public String getStringValue(ModelData arg0, String arg1) {
                    return "my-icon-asc";
                }
            });
            
            binder.setStyleProvider(new ModelStringProvider() {
                public String getStringValue(ModelData arg0, String arg1) {
                    return "x-info-header";
                }
            });
            
            binder.init();
           
            Button bu = new Button("Update all");
            bu.addSelectionListener(new SelectionListener() {
                public void componentSelected(ComponentEvent arg0) {
                    Iterator<ModelData> it = store.getAllItems().iterator();
                    while(it.hasNext()) {
                        binder.update(it.next());
                        // also: store.update(it.next());
                        /* This throws NPE when Item 2 was not expanded:
                           [ERROR] Uncaught exception escaped
                           java.lang.NullPointerException: null
                           at com.extjs.gxt.ui.client.binder.TreeBinder.update(TreeBinder.java:141)*/
                        
                    }
                }
            });
            
            Button bufilter = new Button("Apply filter - !'Item 1'");
            bufilter.addSelectionListener(new SelectionListener() {
                public void componentSelected(ComponentEvent arg0) {
                    StoreFilter filter = new StoreFilter(){
                        public boolean select(Store arg0, ModelData arg1, ModelData arg2, String arg3) {
                            if(!((String)arg2.get("name")).equals("Item 1")) return true;
                            return false;
                        }
                    };
                    store.addFilter(filter);
                    store.filter("");
                }
            });
            
            panel.add(tree);
            panel.addButton(bu);
            panel.addButton(bufilter);
            
            vp.add(panel);
            RootPanel.get().add(vp);
    }
    1) When expanding/ collapsing a node, the icon on the root disappears

    2) The style provided form setStyleProvider() is never used

    3) When doing "update all" and the nodes have not been expanded before, an NPE is thrown (also see inline comments)
    3.1) It would be cool to have an updateAll() to refresh all items on either the Binder or Store...

    4) When filtering, all nodes are expanded afterwards - is this a bug or a feature? I would rather like to keep the expanded/ collapsed state as it was before filtering

    Please also note my questions in topic http://extjs.com/forum/showthread.php?t=36109
    those are also quite crucial for me

    Thanks!!

  7. #7
    Sencha User
    Join Date
    May 2008
    Location
    Germany
    Posts
    59

    Default

    Another bug which I just found with the code above:

    1) Refresh the page
    2) Expand Item 2
    3) Collapse Item 2
    4) Press "Apply filter"

    The Items end up screwed (Item 21 lying over Item 2) ...

    But hey, this will happen rarely I think - I am lucky when it comes to find bugs

  8. #8
    Sencha User
    Join Date
    May 2008
    Location
    Germany
    Posts
    59

    Default

    Another one:

    When filtering "Item 21" so that Item 2 has no child anymore it is still rendered with an expand-arrow.
    This is not very important but may be irritating for users.

    Code:
    StoreFilter filter = new StoreFilter(){
                        public boolean select(Store arg0, ModelData arg1, ModelData arg2, String arg3) {
                            if(!((String)arg2.get("name")).equals("Item 21")) return true;
                            return false;
                        }
                    };

  9. #9
    Sencha User
    Join Date
    May 2008
    Location
    Germany
    Posts
    59

    Default

    Hi

    are there some news concerning theses issues?

  10. #10
    Sencha User darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242

    Default

    1) When expanding/ collapsing a node, the icon on the root disappears
    Fixed.
    2) The style provided form setStyleProvider() is never used
    Fixed.
    When doing "update all" and the nodes have not been expanded before, an NPE is thrown (also see inline comments)
    Fixed.
    4) When filtering, all nodes are expanded afterwards - is this a bug or a feature? I would rather like to keep the expanded/ collapsed state as it was before filtering
    There is a new setExpandOfFilter method on TreeBinder that controls the expand / collapse on filtering.

    Fixes are in SVN.

Page 1 of 2 12 LastLast

Posting Permissions

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