-
12 Apr 2012 6:28 AM #1
Add item to tree with applied filter
Add item to tree with applied filter
Hi,
we have a TreePanel with a TreeStore and a StoreFilterField bind to the store which filters on the displayed name. The items in the store and the children of each group are ordered lexicographically by name. In addition to that we provide a function to add new items to the tree.
When we add items to the tree while a filter value is applied under some circumstances we get either a strange behaviour or the following NullPointerException:
I think the problem is that the TreePanel.onAdd method uses the index of the added item in the unfiltered store to display the item in the filtered tree at the same index.Code:java.lang.NullPointerException at com.extjs.gxt.ui.client.widget.treepanel.TreePanel.onAdd(TreePanel.java:1120) at com.extjs.gxt.ui.client.widget.treepanel.TreePanel$1.storeAdd(TreePanel.java:288) at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:22) at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:1) at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:178) at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:86) at com.extjs.gxt.ui.client.store.TreeStore.doInsert(TreeStore.java:912) at com.extjs.gxt.ui.client.store.TreeStore.insert(TreeStore.java:549) at com.extjs.gxt.ui.client.store.TreeStore.insert(TreeStore.java:563) at com.extjs.gxt.ui.client.store.TreeStore.add(TreeStore.java:207)
Assuming we have the following structure in a tree:
If you apply the filter value "part1" on the above structure you will only see part1 as a subelement of the group parts.Code:parts
myParts1 myParts2 part1
If you add an item to the filtered tree, there are the following three results:Code:parts
part1
- If you add the two items "aPart1" and "aPart2" to the group "parts", these items are added and dispalyed in the correct order.
- If you add the item "myParts11" to the group "parts", the item is added to the tree at the correct index, but displayed after the "part1"-item.
- If you add the item "part2" to the group "parts", you will get the mentioned NullPointerException.
Kind regards,
Uwe
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote