PDA

View Full Version : [CLOSED] Adding a DataList to a FormPanel means the DataList is not scrollable



PeteW
31 Jul 2008, 4:36 AM
If I add a DataList to a FormPanel using AdapterField, the DataList is no longer scrollable.

Here's an example:


import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.DataList;
import com.extjs.gxt.ui.client.widget.DataListItem;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.form.AdapterField;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Scratch implements EntryPoint {

/**
* This is the entry point method.
*/
public void onModuleLoad() {
Viewport viewport = new Viewport();
viewport.setEnableScroll(true);

LayoutContainer container = new LayoutContainer();
container.setLayout(new RowLayout(Orientation.HORIZONTAL));
container.add(createSimpleExample(), new RowData(0.5, 1.0));
container.add(createFieldExample(), new RowData(0.5, 1.0));

viewport.setLayout(new FitLayout());
viewport.add(container);
RootPanel.get().add(viewport);

}

private Component createSimpleExample() {
LayoutContainer container = new LayoutContainer();
container.setLayout(new FitLayout());
container.add(createDataList());
return container;
}

private Component createFieldExample() {
FormPanel container = new FormPanel();
AdapterField listField = new AdapterField(createDataList());
listField.setFieldLabel("List");
FormData fd = new FormData();
fd.setHeight(300);
container.add(listField,fd);
return container;
}

private DataList createDataList() {
DataList dataList = new DataList();
dataList.setScrollMode(Scroll.AUTO);
for (int index = 0; index < 50; ++index) {
DataListItem item = new DataListItem();
item.setChecked(index % 3 == 0);
item.setText("item " + index);
dataList.add(item);
}
return dataList;
}

}

Regards, Pete

PeteW
31 Jul 2008, 8:49 AM
sorry, forgot to add the following...

- GXT version: 1.0.1
- Host mode / web mode / both: both
- Browser and version: firefox 3.0.1
- Operating System: vista

darrellmeyer
2 Aug 2008, 8:54 AM
You need to set the height of the list to match the adapter field:


private DataList createDataList() {
DataList dataList = new DataList();
dataList.setHeight(300);
dataList.setScrollMode(Scroll.AUTO);
for (int index = 0; index < 50; ++index) {
DataListItem item = new DataListItem();
item.setChecked(index % 3 == 0);
item.setText("item " + index);
dataList.add(item);
}
return dataList;
}