gpt4 book ai didi

GWT 2.1 没有分页的数据展示小部件

转载 作者:行者123 更新时间:2023-12-04 15:15:57 25 4
gpt4 key购买 nike

我正在尝试构建一个包含大型数据集的表,并希望避免分页。 (我想做一些类似于 Yahoo Mail 网格的事情,它在绘制网格后检索数据。我认为最初检索前 100 封邮件,然后仅在用户向下滚动后才检索邮件)

我见过的数据展示小部件的例子包括分页。可以做我想做的吗?

编辑:您也可以将其称为无限滚动表

最佳答案

GWT Showcase 中有一个这样的例子

/**
* A scrolling pager that automatically increases the range every time the
* scroll bar reaches the bottom.
*/
public class ShowMorePagerPanel extends AbstractPager {

/**
* The default increment size.
*/
private static final int DEFAULT_INCREMENT = 20;

/**
* The increment size.
*/
private int incrementSize = DEFAULT_INCREMENT;

/**
* The last scroll position.
*/
private int lastScrollPos = 0;

/**
* The scrollable panel.
*/
private final ScrollPanel scrollable = new ScrollPanel();

/**
* Construct a new {@link ShowMorePagerPanel}.
*/
public ShowMorePagerPanel() {
initWidget(scrollable);

// Handle scroll events.
scrollable.addScrollHandler(new ScrollHandler() {
public void onScroll(ScrollEvent event) {
// If scrolling up, ignore the event.
int oldScrollPos = lastScrollPos;
lastScrollPos = scrollable.getScrollPosition();
if (oldScrollPos >= lastScrollPos) {
return;
}

HasRows display = getDisplay();
if (display == null) {
return;
}
int maxScrollTop = scrollable.getWidget().getOffsetHeight()
- scrollable.getOffsetHeight();
if (lastScrollPos >= maxScrollTop) {
// We are near the end, so increase the page size.
int newPageSize = Math.min(
display.getVisibleRange().getLength() + incrementSize,
display.getRowCount());
display.setVisibleRange(0, newPageSize);
}
}
});
}

/**
* Get the number of rows by which the range is increased when the scrollbar
* reaches the bottom.
*
* @return the increment size
*/
public int getIncrementSize() {
return incrementSize;
}

@Override
public void setDisplay(HasRows display) {
assert display instanceof Widget : "display must extend Widget";
scrollable.setWidget((Widget) display);
super.setDisplay(display);
}

/**
* Set the number of rows by which the range is increased when the scrollbar
* reaches the bottom.
*
* @param incrementSize the incremental number of rows
*/
public void setIncrementSize(int incrementSize) {
this.incrementSize = incrementSize;
}

@Override
protected void onRangeOrRowCountChanged() {
}
}

关于GWT 2.1 没有分页的数据展示小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3129104/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com