2010-06-27 16 views
6

Estoy tratando de construir una tabla con un gran conjunto de datos y me gustaría evitar la paginación. (Me gustaría hacer algo similar a la cuadrícula de Yahoo Mail que recupera datos después de dibujar la cuadrícula. Creo que inicialmente se recuperan los primeros 100 correos y luego solo se recupera después de que el usuario se desplaza hacia abajo)GWT 2.1 Presentaciones de datos Widgets sin paginación

El ejemplo del widget de presentación de datos que he visto incluir paginación. ¿Es posible hacer lo que quiero?

edición: También podría llamar a esta mesa de un desplazamiento infinito

Respuesta

1

Dean ya mencionó Ext GWT pero me gustaría sugerir SmartGWT's implementation también.

+0

Su enlace no era correcto, pero lo encontré de todos modos. Me gusta: http://www.smartclient.com/smartgwt/showcase/#featured_grid_live – Tihom

0

Sí, es posible. Solía ​​haber un ejemplo de eso llamado DynaGrid here pero ese enlace está muerto ahora. No he podido encontrarlo en ningún otro lado (nota: eso no es lo mismo que el DynaGrid on SourceForge). Puede contactar al autor, Reinier Zwitserloot, para solicitar una copia de su DynaGrid. También puede buscar en el GWT Group y, si no encuentra nada, publicar allí preguntando si alguien más sabe dónde encontrarlo.

+0

He intentado buscar un dynagrid pero no han sido capaces de encontrarlo. Además, me gustaría utilizar un widget que esté siendo utilizado por otros y se mantenga. Es por eso que quería usar el widget de presentación de datos. – Tihom

4

Hay un exemple de esto en el 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() { 
    } 
} 
Cuestiones relacionadas