问题
I'm using GXT 3.0.0b.
I have a Grid on ContentPanel. When I set ContentPanel width explicitly there is no problem with scrolling. But when I put grid in VerticalLayoutContainer the vertical scrollbar of the grid disappears and scrolling is possible only with mouse wheel.
Does anybody know how to solve this problem?
回答1:
Finally I've managed to solved this problem. The answer was rather elegant: when I added grid to VerticalLayoutContainer I should specify VerticalLayoutData parameter.
Example:
verticalLayoutContainer.add(grid, new VerticalLayoutData(1, 1));
You can also pass fraction, for example, 0.6 will set width (or height) to 60%. If you pass -1 then component will have it's own default pixel size.
回答2:
I had the same problem with a Grid
in a ContentPanel
, that is, the grid didn't show a vertical scrollbar. I used ContentPanel#forceLayout
immediately after adding the grid to the panel, and it resolved the problem. Here's the actual code:
Grid<Pet> grid = new Grid<>(listStore, columnModel);
grid.setBorders(true);
grid.setColumnReordering(true);
grid.setLoadMask(true);
grid.setSelectionModel(selectionModel);
grid.setView(createGridView());
ContentPanel contentPanel = new ContentPanel();
contentPanel.setHeaderVisible(false);
contentPanel.add(grid);
contentPanel.forceLayout(); // <---- this is the line that fixed the problem!
回答3:
I realize this is old, but I wanted to say that Artem's solution helped me resolve a similar issue with GXT 2.3 grid scrolling. In our case we are using a FitLayout, so including a FitData(0) with the add() calls resolved our issue.
Our issue was that we have a TreeGrid, and when one of the Tree items is expanded, the grid jumps the expanded rows out of view. Adding the FitData() object when adding the grid to the root panel resolved the issue.
来源:https://stackoverflow.com/questions/12050354/gxt-3-grid-scrolling-issue