-
20 Jun 2011 11:22 PM #1
TabPanel adding new tab from child tab
TabPanel adding new tab from child tab
Hello, I am glad to be here (this is my first post). I hope I can find help here, and I also hope I will be able to help others.
I am trying to develop an application which requires working with TabPanel component.
In a tab I have a Grid which keeps some records (each record is a Tabel object defined by me). I want to be able to do the following:
When I double-click on a record I want a new tab-item to appear in the tabpanel, tab-item which contains the records contained in the table which have just been double-clicked on.
I have the following:
I thought I need somehow to get the parent by getParent(), I manage to get to the TabPanel and .. let's say .. get it's ID, but I just don't know how to add a new TabItem.Code:grid.addListener(Events.RowDoubleClick, new Listener<GridEvent<BeanModel>>() { @Override public void handleEvent(GridEvent<BeanModel> be) { String tableName = be.getModel().get("tableName"); TableDetailsGrid tdg = new TableDetailsGrid(); //Here I want to add somehow the new object "TableDetailsGrid" to the big TabPanel } });
Any suggestion would be very valuable. Thanks!
-
20 Jun 2011 11:29 PM #2
-
20 Jun 2011 11:34 PM #3
My problem is that for each TabItem I have a class and I put them all together in the EntryPoint. I don't know could I keep the TabPanel (which is defined in the entrypoint class) and to make it available for all the classes

ps: thanks for the quick answer.
-
21 Jun 2011 12:12 AM #4
Figured it out. It looks like this:
Hope it will help someone in the futureCode:grid.addListener(Events.RowDoubleClick, new Listener<GridEvent<BeanModel>>() { @Override public void handleEvent(GridEvent<BeanModel> be) { String tableName = be.getModel().get("tableName"); TableDetailsGrid tdg = new TableDetailsGrid(); TabItem ti = new TabItem(tableName); ti.add(tdg); ti.setClosable(true); ((TabPanel) grid.getParent().getParent().getParent() .getParent()).add(ti); ((TabPanel) grid.getParent().getParent().getParent() .getParent()).setSelection(ti); } });
-
21 Jun 2011 12:20 AM #5
You can use the com.extjs.gxt.ui.client.Registry class.
Example.
In your entry point,
And in your another GUI classes,Code:YourTabPanel tabPanel = new YourTabPanel(); Registry.register("tabPanel", tabPanel); . . .
Code:YourTabPanel tabPanel = Registry.get("tabPanel"); . . .
-
21 Jun 2011 12:32 AM #6
Thanks a lot, actually that Registry approach will help me a lot with the nest task

Thank you guys.
-
29 Nov 2012 9:22 PM #7



Reply With Quote