I have a viewport inside which I have two tabs. Both tabs have treepanels and tree is coming dynamically from same action class.
Now I want to collapse the expanded nodes when I switch the tab.
I tried using "deactivate" event like this:

alert("before deactivate");


This event is not being called.
The tree panel is inserted in the form of object, I have not created Tree panel as an item in tab panel but I created another Js file for Tree-Panel and then created an object of that panel and then inserted that object as an item in tab panel.

How can I collapse nodes on switching Tab???
Also I want that my tree should not collapse fully i.e. If my tree is like:


Then after switching tab, I need to have my tree as:
Please reply soon
Thanks in advance