PDA

View Full Version : Change the component set on specific viewport area



iadded
11 Sep 2011, 4:07 AM
Hi

I've been using GXT for the last 2 month to develop a small desktop-like application - and so far i am very pleased with it !!!

After looking at the examples and searching the forum - I need assistance implementing the following functionality :

I have a ViewPort set with 5 different components (1 in each area - each component extends ContentPanel).
Now - i want to load a different component in the center area (remove the existing component and add a different one).

I could not find any example doing that.
I wanted to try and remove the existing component - but i could not find a way to get the component that is currently loaded in the center area (the application will load different components into the area depending on the application state - so i need a way to "get" the current loaded component).
I even tried adding the components to the container using viewport.insert(widget, index, LayoutData) instead of viewport.add(widget) - assuming i can then use the index to get the widget that needs to be removed - but i received an IndexOutOfBound exception when inserting.

How can i set the index and retrive the component based on the set index ?
What is the "proper" solution for changing the component ?

Will appreciate any help
Inbal

iadded
12 Sep 2011, 7:21 AM
Hi

I finally find a solution that works.
I set a specific Id on all content panels that should be placed in the center area - and used the ViewPort.getItemByItemId to remove the loaded panel before i add the new panel into the center area.

This solution works fine.
I'm still wondering about the insert method :viewport.insert(widget, index, layoutData)

Why is this not working ? why do i get an IndexOutOfBound Exception ?
Will appreciate any help on this - what is the "proper solution for this task
Thanks
Inbal