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:
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)
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.

Assuming we have the following structure in a tree:
myParts1 myParts2 part1
If you apply the filter value "part1" on the above structure you will only see part1 as a subelement of the group parts.
If you add an item to the filtered tree, there are the following three results:

  1. If you add the two items "aPart1" and "aPart2" to the group "parts", these items are added and dispalyed in the correct order.
  2. 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.
  3. If you add the item "part2" to the group "parts", you will get the mentioned NullPointerException.

Is this a bug and can you fix it?

Kind regards,