Reputation: 3608
Good day. I'm making a gwt application with tables using GWT Grid
. Now, I want my GWT Grid
to have a scrollbar
when rowCount is greater than 15. The header is not part of the scrollable area.
My problems are:
My current code will allow scrolling when rowCount > 15 including the header. Please help. Thanks in advance.
Upvotes: 3
Views: 7183
Reputation: 64541
Maybe it's time to switch to cell widgets, and DataGrid.
Upvotes: 6
Reputation: 764
Scrolling
I won't dig deep into GWT with this post but I'll try to give some hints on how to do the scrolling part.
If your table's data is wrapped in a separate tag than the table's body, then it shouldn't be a problem. If the table's structure is similar to the following, it shouldn't be a problem:
<table>
<thead>
<tr>
<th>ColumnHeader1</th>
<th>ColumnHeader2</th>
</tr>
</thead>
<tbody>
<tr>
<th>Data1</th>
<th>Data2</th>
</tr>
</tbody>
</table>
To make the data part vertically scrollable, you should add a CSS style to the <tbody>
element which sets overflow-y: scroll;
when the rowcount is greater than 15. Also you need to set the height or limit it's height by other means (wrapping container) for the scrollbar to appear.
To set the height, I'd consider to get the <tbody>
's offset height right after the 15th row has been added and force it to stay at that. It might go like this:
tbodyElement.setHeight(tbodyElement.getOffsetHeight());
Remember, this has to be done right after adding the 15th row.
Sorting
For that you should wrap your column header names in some kind of a Widget
. It could be a HTML
or a Label
for example. You just need to add ClickHandler
s to them and some styling to fill the whole cell and the cursor to switch to a hand with CSS cursor: pointer;
while hovering on it.
Conclusion
Well, this was my light overview of this. Without seeing the code you've done it's hard to go any further.
Upvotes: 0