-
30 Nov 2010 4:10 AM #1
Layout problem with Grid
Layout problem with Grid
Hi all,
I've a problem sizing a layout for grid, I set to all parent a FitLayout but it has a wrong size as shown in fig:

if the grid size is full (50 elements) its layout goes over the south panel (without scroll)
These are the property I've set:
LayoutClass: (it extends LayoutContainer)
Tabs:Code:LayoutContainer center = new LayoutContainer(new FitLayout()); center.setScrollMode(Scroll.AUTO); BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER); centerData.setMargins(new Margins(0)); centerData.setSplit(false); centerData.setCollapsible(true); centerData.setFloatable(true); Tabs tabs = new Tabs(); center.add(tabs); add(center, centerData);
Grid (it extends LayoutContainer):Code:tabPanel = new TabPanel(); tabPanel.setLayoutData(new FitLayout()); tabPanel.setAutoHeight(true); tabPanel.setResizeTabs(true); tabPanel.setAnimScroll(true); tabPanel.setTabScroll(true); tabPanel.setCloseContextMenu(true); setLayout(new FitLayout()); add(tabPanel); public void addTabWithWidget(String text, LayoutContainer p) { if (!hashMap.containsKey(text)) { TabItem item = new TabItem(); item.setLayout(new FitLayout()); // item.setText("New Tab " + ++index); item.setText(text); item.setClosable(index != 0); //item.addText("Tab Body " + index); item.add(p); item.addStyleName("pad-text"); item.addListener(Events.Close, new Listener<BaseEvent>() { public void handleEvent(BaseEvent be) { hashMapRecalc(); } }); tabPanel.add(item); tabPanel.setSelection(tabPanel.getItem(tabPanel.getItemCount() - 1)); hashMap.put(text, tabPanel.getItemCount() - 1); index++; } else { tabPanel.setSelection(tabPanel.getItem(Integer.parseInt(hashMap.get(text).toString()))); } }
thanks @allCode:setLayout(new FlowLayout(10)); grid.setLoadMask(true); grid.setBorders(true); grid.setAutoExpandColumn("nome"); grid.setLayoutData(new FitLayout()); grid.setAutoHeight(true); ContentPanel panel = new ContentPanel(); panel.setFrame(true); panel.setCollapsible(true); panel.setAnimCollapse(false); // panel.setIcon(Resources.ICONS.table()); panel.setHeading("PatchFinder List"); panel.add(grid); panel.setLayoutData(new FitLayout()); panel.setAutoHeight(true); //panel.setSize(800, 400); panel.setBottomComponent(toolBar); grid.getAriaSupport().setLabelledBy(panel.getId()); add(panel);
-
30 Nov 2010 4:12 AM #2
Is the "panel" the only child of the layoutcontainer, which is a child of the tabitem?
Also autoheight is not fully supported and cannot be supported by definition with a FitLayout.
-
30 Nov 2010 4:18 AM #3
Yes panel is the only child.
If I don't use autoheight the grid height is 0 and I cannot see any elements, if I set a manual size everything goes fine but I want avoid to use it because will be different with a different screen resolution.
thanks
-
30 Nov 2010 4:22 AM #4
Thats why GXT has a layoutsystem.if I set a manual size everything goes fine but I want avoid to use it because will be different with a different screen resolution.
Give the TabItem a FitLayout. Also gve your LayoutContainer a FitLayout and the ContentPanel a FitLayout. Than remove autoheight from the grid and the ContentPanel.
Also why do you have an extra LayoutContainer in between there? Cannot you better add the ContentPanel directly to the TabItem?
-
30 Nov 2010 5:03 AM #5
What is the extra LayoutContainer??
and I use the ContentPanel in the grid just to set the content and the bottom toolbar (to paginate)
just like:
http://www.sencha.com/examples/explorer.html#paging
am I wrong?
-
30 Nov 2010 5:06 AM #6
That sounds like oyu use an extra LayoutCOntainer where you put in the panel that holds the grid.Grid (it extends LayoutContainer):
I am not saying you should remove that.and I use the ContentPanel in the grid just to set the content and the bottom toolbar (to paginate)
-
30 Nov 2010 5:36 AM #7
I've added a ContentPanel and cut off the both SetAutoHeight result is:

Tabs:
Grid:Code:public void addTabWithWidget(String text, LayoutContainer p) { if (!hashMap.containsKey(text)) { TabItem item = new TabItem(); ContentPanel cp = new ContentPanel(); cp.setHeading(text); cp.add(p); cp.setLayout(new FitLayout()); item.setLayout(new FitLayout()); item.setText(text); item.setClosable(index != 0); item.add(cp); item.addStyleName("pad-text"); item.addListener(Events.Close, new Listener<BaseEvent>() { public void handleEvent(BaseEvent be) { hashMapRecalc(); } }); tabPanel.add(item); tabPanel.setSelection(tabPanel.getItem(tabPanel.getItemCount() - 1)); hashMap.put(text, tabPanel.getItemCount() - 1); index++; } else { tabPanel.setSelection(tabPanel.getItem(Integer.parseInt(hashMap.get(text).toString()))); } }
Code:grid.setLoadMask(true); grid.setBorders(true); grid.setAutoExpandColumn("nome"); grid.setLayoutData(new FitLayout()); //grid.setAutoHeight(true); ContentPanel panel = new ContentPanel(); panel.setFrame(true); panel.setCollapsible(true); panel.setAnimCollapse(false); // panel.setIcon(Resources.ICONS.table()); panel.setHeading("PatchFinder List"); panel.add(grid); panel.setLayoutData(new FitLayout()); //panel.setAutoHeight(true); //panel.setSize(800, 400); panel.setBottomComponent(toolBar); grid.getAriaSupport().setLabelledBy(panel.getId()); add(panel);
-
30 Nov 2010 5:40 AM #8
Do you have a FitLayout on the LayoutContainer that holds the ContentPanel with the grid?
-
30 Nov 2010 5:44 AM #9
I've a FlowLayout at the start of Grid class:
and I add the CP in this LayoutContainer (I've also tried before to put a FitLayout without results)Code:setLayout(new FlowLayout(10));
-
30 Nov 2010 5:45 AM #10
A flowlayout is not sizing anything. You need to use a FitLayout there, else your layoutchain is broken.
Also your "panel" has no layout set.
Similar Threads
-
Layout/Grid problem
By marcinKozlowicz in forum Ext GWT: Help & Discussion (1.x)Replies: 57Last Post: 15 Dec 2009, 11:19 AM -
Grid Layout Problem in Firefox
By kckc1234 in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 15 Dec 2009, 8:17 AM -
problem with grid in column layout
By zoli in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 24 Aug 2008, 2:06 AM -
page layout/grid problem
By mike1993 in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 30 Apr 2008, 1:49 PM -
Grid Resizing/Layout problem
By Novael in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 22 Jan 2008, 4:37 PM


Reply With Quote