PDA

View Full Version : [FIXED] setIconProvider(ModelStringProvider) on TreeBinder not working on roots



LukasP
21 May 2008, 1:51 AM
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?

LukasP
22 May 2008, 2:13 PM
setStyleProvider on TreeBinder does not seem to have any effect at all...

darrellmeyer
22 May 2008, 8:03 PM
I am not seeing any problems. Please post some simple test code that demonstrates the problem you are seeing.

ceric35
22 May 2008, 11:35 PM
I have same bug !

darrellmeyer
23 May 2008, 5:23 AM
Please post some sample code.

LukasP
23 May 2008, 7:06 AM
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.



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!!

LukasP
23 May 2008, 7:30 AM
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 :D

LukasP
23 May 2008, 7:47 AM
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.



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;
}
};

LukasP
28 May 2008, 11:01 PM
Hi

are there some news concerning theses issues? :)

darrellmeyer
29 May 2008, 6:54 AM
1) When expanding/ collapsing a node, the icon on the root disappearsFixed.

2) The style provided form setStyleProvider() is never usedFixed.

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 filteringThere is a new setExpandOfFilter method on TreeBinder that controls the expand / collapse on filtering.

Fixes are in SVN.

LukasP
29 May 2008, 11:43 AM
Thanks so much! \:D/

mmiotk
1 Jun 2008, 10:14 PM
I've problem with displaying custom icons on the tree nodes. When I used gxt-1.0-beta2, my custom icons on tree nodes were displayed, but when I migrate my application to gxt-1.0-beta3, these icon's aren't displayed. Look at this screenshot:


http://sejmisja.pl/marcin/problem1.jpg

I set the icon to tree LEAF in the same way as to tree NODE.. by calling:

FOR NODE:

itemDict.setIconStyle("cbs-icon-sitemodel-dictionary");FOR LEAF:

i_item.setIconStyle("cbs-icon-sitemodel-dictionary-add");My CSS file contains:


.cbs-icon-sitemodel-dictionary {
background: url(icons/books_016.gif) no-repeat;
}

.cbs-icon-region-add {
background: url(icons/database_add.gif) no-repeat;
}When I don't call the method setIconStyle for tree NODE, gxt displays the default folder icon for it.

gslender
1 Jun 2008, 11:46 PM
Try changing the CSS entry to...


.cbs-icon-region-add {
background-image: url(icons/database_add.gif) !important;
}

???

mmiotk
2 Jun 2008, 12:15 AM
Yes, i tried


.cbs-icon-sitemodel-dictionary {
background-image: url(icons/books016.gif) !important;
}but it's the same effect: tree without icons on nodes (on the leafs icons are exists).


Icons are displayed when I define CSS style for LEAF:


.cbs-icon-sitemodel-dictionary-list {
background-image: url(icons/table.gif) !important;
}but aren't displayed when I define CSS style for NODE:


.cbs-icon-sitemodel-dictionary {
background-image: url(icons/books016.gif) !important;
}I reminder that it works with GXT-beta2.

mmiotk
2 Jun 2008, 12:20 AM
there is one more behavior: when I remove all leafs from the tree node, the icon for this node suddenly appers :) and then, when i add one leaf to this node again, the icon for this node disappers.

gslender
2 Jun 2008, 2:03 AM
mmiotk, you'd be best to post a fresh bug report - posting against another bug, that was fixed is probably a bad way to get this resolved....