PDA

View Full Version : Vertical scroll bar brings horizontal scroll bar



smiletolead
24 Nov 2009, 11:31 AM
Hi all,
I am finding one behavior with GXT layout container. Whenever vertical scroll bar appears, it is bringing up horizontal scroll bar also. Has anyone faced this issue?


public class LayoutScrollBar implements EntryPoint {
/**
* This is the entry point method.
*/
private static int rowCount = 50;
private static int columnCount = 50;

private ContentPanel cp;

public void onModuleLoad() {
cp = new ContentPanel();
cp.setBodyBorder(true);
cp.setHeading("Buffered Grid");
cp.setButtonAlign(HorizontalAlignment.CENTER);
cp.setCollapsible(true);
cp.setExpanded(false);
cp.setLayout(new FitLayout());
Viewport vp = new Viewport();
RowLayout rl1 = new RowLayout();
LayoutContainer mdContainer = new LayoutContainer(rl1);

ContentPanel cp1 = new ContentPanel();
cp1.setBodyBorder(true);
cp1.setHeading("Buffered Grid");
cp1.setButtonAlign(HorizontalAlignment.CENTER);
cp1.setLayout(new FitLayout());

CAMasterDetail md = new CAMasterDetail();

RowLayout rl = new RowLayout();
LayoutContainer detailSection = new LayoutContainer(rl);
detailSection.setBorders(true);
mdContainer.add(detailSection, new RowData(1, 1));
cp.setHeight(400);
cp1.setHeight(200);
detailSection.setScrollMode(Scroll.AUTO);
detailSection.add(cp, new RowData(1, -1));
detailSection.add(cp1, new RowData(1, -1));

vp.setLayout(new FitLayout());
vp.add(mdContainer);
createGrid(rowCount, columnCount);
RootPanel.get().add(vp);
}

private void createGrid(final int rows, final int columns) {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ListStore<Stock> store = new ListStore<Stock>();
for (int i = 0; i < columnCount; i++) {
ColumnConfig column = new ColumnConfig();
column.setWidth(100);
column.setHeader("Column Name" + i);
column.setId("columnId" + i);
configs.add(column);
}
store.add(TestData.getStocks(rowCount, columnCount));
ColumnModel cm = new ColumnModel(configs);
Grid<Stock> grid = new Grid<Stock>(store, cm);
grid.setTrackMouseOver(false);
grid.setLoadMask(true);
grid.setBorders(true);

BufferView view = new BufferView();
// view.setAutoFill(true);
// view.setForceFit(true);
view.setScrollDelay(10);
view.setRowHeight(19);
grid.setView(view);
cp.add(grid, new FitData());
cp.layout();
}
}



public class Stock extends BaseModel {

public Stock(int columnCount, int rowCount) {
for (int i = 0; i < columnCount; i++) {
set("columnId" + i, "This is Data" + rowCount);
}
}

public Stock() {
set("columnId1", "Column data");
}

}


In this sample, you can observe that expanding the first content panel brings up vertical scroll bar along with horizontal scroll bar.

Thanks,
Ganesh

kolli
24 Nov 2009, 12:35 PM
That is because the vertical scroll bar will take up some space, so to accomadate the actual size a Horizontal scroll bar is put in automatically.
As detailSection.setScrollMode(Scroll.AUTO);

you can try just having detailSection.setScrollMode(Scroll.AUTOY); or adjust the width of the window to remove the extra width

smiletolead
24 Nov 2009, 6:14 PM
If I set detailSection.setScrollMode(Scroll.AUTOY), I do not get horizontal scrollbar at all even when it is required.
The layout is taking 100% space, the Vertical scrollbar is overlapping the content behind it.

smiletolead
25 Nov 2009, 6:07 AM
I just wanted to know if it is GXT default behavior or is there any simple solution for this

smiletolead
26 Nov 2009, 1:14 AM
detailSection.setAdjustForScroll(true); gives me what I expect.

Thanks,
Ganesh