PDA

View Full Version : [CLOSED] Bottom of Scrollbar hidden in DataList



Zorn
31 Jul 2008, 4:37 AM
Hi,
When i set a height to contentPanel, the bottom of the scrollbar and the last DataListItem are hidden. But when i set the height to the dataList, that's ok.
Maybe layout don't take in mind the height of header and toolbar ?

Here's the code :

public void onModuleLoad() {
ContentPanel contentPanel = new ContentPanel();
contentPanel.setHeaderVisible(false);
ToolBar toolBar = new ToolBar();
toolBar.add(new SeparatorToolItem());
contentPanel.setTopComponent(toolBar);
DataList dataList = new DataList();
contentPanel.add(dataList);
contentPanel.setLayout(new FitLayout());
//dataList.setHeight(100);
contentPanel.setHeight(100);
DataListItem listItem = new DataListItem();
listItem.setText("1");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("2");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("3");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("4");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("5");
dataList.add(listItem);
Window w = new Window();
w.setHeight(400);
w.add(contentPanel);
w.show();
}

darrellmeyer
2 Aug 2008, 10:04 AM
In general, you should have your layouts cascade from the outer container rather than size the child components directly. Try this code:


public void onModuleLoad() {
ContentPanel contentPanel = new ContentPanel();
contentPanel.setHeaderVisible(false);

ToolBar toolBar = new ToolBar();
toolBar.add(new SeparatorToolItem());
contentPanel.setTopComponent(toolBar);
DataList dataList = new DataList();
contentPanel.add(dataList);

contentPanel.setLayout(new FitLayout());
// dataList.setHeight(100);
// contentPanel.setHeight(75);
DataListItem listItem = new DataListItem();
listItem.setText("1");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("2");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("3");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("4");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("5");
dataList.add(listItem);


Window w = new Window();
w.setHeight(400);
w.setLayout(new RowLayout());
w.add(contentPanel, new RowData(1, 100));
w.show();
}Also, the 2nd content panel is not needed. Window is a content panel so it supports a top component. You could do something like this:


public void onModuleLoad() {
Window w = new Window();
w.setHeight(400);

ToolBar toolBar = new ToolBar();
toolBar.add(new SeparatorToolItem());
w.setTopComponent(toolBar);
DataList dataList = new DataList();
dataList.setHeight(75);

w.add(dataList);


DataListItem listItem = new DataListItem();
listItem.setText("1");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("2");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("3");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("4");
dataList.add(listItem);
listItem = new DataListItem();
listItem.setText("5");
dataList.add(listItem);

w.show();
}