2010-06-27 49 views
6

我想建立一個大數據集的表,並希望避免分頁。 (我想做一些與Yahoo Mail網格類似的東西,它在網格被繪製後檢索數據,我認爲最初前100個郵件被檢索,然後郵件只在用戶滾動後才被檢索)GWT 2.1數據演示小部件沒有分頁

數據呈現小部件我見過包括分頁。有可能做我想做的事嗎?

編輯:你也可以把這叫做無限滾動表

回答

1

院長已經提到了Ext GWT,但我也想建議SmartGWT's implementation

+0

您的鏈接不正確,但無論如何我發現它。我喜歡它:http://www.smartclient.com/smartgwt/showcase/#featured_grid_live – Tihom 2010-07-23 18:51:40

0

是的,這是可能的。曾經有一個叫DynaGrid here的例子,但是現在這個鏈接已經死了。我一直無法在其他地方找到它(注意:這與DynaGrid on SourceForge不一樣)。您可以聯繫作者Reinier Zwitserloot,詢問有關獲取DynaGrid的副本。您也可以搜索GWT Group,如果您沒有找到任何內容,請發帖詢問是否有其他人知道在哪裏可以找到它。

+0

個例我試圖尋找一個dynagrid,但一直沒能找到它。另外,我想使用一個正在被其他人使用並維護的小部件。這就是爲什麼我想使用數據呈現小部件。 – Tihom 2010-07-07 14:36:59

4

這方面有在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() { 
    } 
}