com.extjs.gxt.ui.client.widget.grid
Class LiveGridView

java.lang.Object
  extended by com.extjs.gxt.ui.client.event.BaseObservable
      extended by com.extjs.gxt.ui.client.widget.grid.GridView
          extended by com.extjs.gxt.ui.client.widget.grid.LiveGridView
All Implemented Interfaces:
Observable

public class LiveGridView
extends GridView

LiveGridView for displaying large amount of data. Data is loaded on demand as the user scrolls the grid.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.extjs.gxt.ui.client.widget.grid.GridView
GridView.GridViewImages
 
Field Summary
protected  El liveScroller
           
protected  ListStore<ModelData> liveStore
           
protected  int liveStoreOffset
           
protected  int totalCount
           
protected  int viewIndex
           
 
Fields inherited from class com.extjs.gxt.ui.client.widget.grid.GridView
activeHdIndex, autoFill, borderWidth, cm, columnListener, deferEmptyText, ds, el, emptyText, enableHdMenu, enableRowBody, focusEl, focusEnabled, footer, forceFit, grid, header, headerColumnIndex, headerDisabled, images, innerHd, lastViewWidth, listener, mainBody, mainHd, mainWrap, overRow, preventScrollToTopOnRefresh, scroller, scrollOffset, selectable, sortState, splitterWidth, templates, userResized, vbar, viewConfig, widgetList
 
Constructor Summary
LiveGridView()
           
 
Method Summary
protected  void afterRender()
           
protected  void calculateVBar(boolean force)
           
protected  GridEvent<?> createComponentEvent(com.google.gwt.user.client.Event event)
           
protected  void doLoad()
           
 int getCacheSize()
          Returns the numbers of rows that should be cached.
protected  int getCalculatedRowHeight()
           
protected  int getLiveScrollerHeight()
           
protected  int getLiveStoreCalculatedIndex(int index)
           
 int getLoadDelay()
          Returns the amount of time before loading is done.
 double getPrefetchFactor()
          Returns the prefetchFactor.
 int getRowHeight()
          Returns the height of one row.
protected  int getScrollAdjust()
           
 int getVisibleRowCount()
           
 void handleComponentEvent(GridEvent ge)
           
protected  void initData(ListStore ds, ColumnModel cm)
          Initializes the data.
protected  boolean isCached(int index)
           
protected  boolean isHorizontalScrollBarShowing()
           
protected  boolean loadLiveStore(int offset)
           
protected  void notifyShow()
           
protected  void onColumnWidthChange(int column, int width)
           
protected  void onRemove(ListStore<ModelData> ds, ModelData m, int index, boolean isUpdate)
           
 void refresh()
          Refreshed the view.
 void refresh(boolean headerToo)
          Rebuilds the grid using its current configuration and data.
protected  void renderUI()
           
protected  void resize()
           
 void scrollToTop()
          Scrolls the grid to the top.
 void setCacheSize(int cacheSize)
          Sets the amount of rows that should be cached (default to 200).
 void setLoadDelay(int loadDelay)
          Sets the amount of time before loading is done (defaults to 200).
 void setPrefetchFactor(double prefetchFactor)
          Sets the pre-fetch factor (defaults to .2).
 void setRowHeight(int rowHeight)
          Sets the height of one row (defaults to 20).
protected  boolean shouldCache(int index)
           
protected  void updateRows(int newIndex, boolean reload)
           
 
Methods inherited from class com.extjs.gxt.ui.client.widget.grid.GridView
addRowStyle, applyEmptyText, autoExpand, createContextMenu, detachWidget, detachWidgets, doAttach, doDetach, doRender, doSort, ensureVisible, findCell, findCellIndex, findRow, findRowIndex, fitColumns, fly, focusCell, focusGrid, focusRow, getBody, getCell, getCellIndex, getCellSelectorDepth, getColumnData, getColumnStyle, getColumnWidth, getEditorParent, getEmptyText, getHeader, getHeaderCell, getImages, getOffsetWidth, getRenderedValue, getRow, getRow, getRows, getRowSelectorDepth, getScroller, getScrollState, getSortState, getTotalWidth, getViewConfig, getWidget, getWidgetCell, hasRows, init, initElements, initListeners, initTemplates, initUI, insertRows, isAdjustForHScroll, isAutoFill, isForceFit, isShowDirtyCells, isShowInvalidCells, isSortingEnabled, layout, layout, newColumnHeader, notifyHide, onAdd, onBeforeDataChanged, onCellDeselect, onCellSelect, onClear, onClick, onColumnMove, onColumnSplitterMoved, onDataChanged, onHeaderChange, onHeaderClick, onHiddenChange, onHighlightRow, onMouseDown, onRowDeselect, onRowOut, onRowOver, onRowSelect, onUpdate, prepareData, processRows, refreshRow, removeRow, removeRowStyle, render, renderFooter, renderHeader, renderRows, renderWidgets, restoreScroll, setAdjustForHScroll, setAutoFill, setCellSelectorDepth, setEmptyText, setForceFit, setRowSelectorDepth, setShowDirtyCells, setShowInvalidCells, setSortingEnabled, setViewConfig, stopEditing, syncHeaderScroll, syncHScroll, syncScroll, templateAfterMove, templateOnAllColumnWidthsUpdated, templateOnColumnHiddenUpdated, templateOnColumnWidthUpdated, templateOnLayout, templateUpdateColumnText, updateAllColumnWidths, updateColumnHidden, updateColumnWidth, updateHeaderSortState, updateSortIcon
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, callListener, fireEvent, fireEvent, getFiresEvents, getListeners, hasActiveEvent, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

liveScroller

protected El liveScroller

liveStore

protected ListStore<ModelData> liveStore

liveStoreOffset

protected int liveStoreOffset

totalCount

protected int totalCount

viewIndex

protected int viewIndex
Constructor Detail

LiveGridView

public LiveGridView()
Method Detail

getCacheSize

public int getCacheSize()
Returns the numbers of rows that should be cached.

Returns:
the cache size

getLoadDelay

public int getLoadDelay()
Returns the amount of time before loading is done.

Returns:
the load delay in milliseconds

getPrefetchFactor

public double getPrefetchFactor()
Returns the prefetchFactor.

Returns:
the prefetchFactor

getRowHeight

public int getRowHeight()
Returns the height of one row.

Returns:
the height of one row

getVisibleRowCount

public int getVisibleRowCount()

handleComponentEvent

public void handleComponentEvent(GridEvent ge)
Overrides:
handleComponentEvent in class GridView

refresh

public void refresh()
Refreshed the view. Reloads the store based on the current settings


refresh

public void refresh(boolean headerToo)
Description copied from class: GridView
Rebuilds the grid using its current configuration and data.

Overrides:
refresh in class GridView
Parameters:
headerToo - true to refresh the header

scrollToTop

public void scrollToTop()
Description copied from class: GridView
Scrolls the grid to the top.

Overrides:
scrollToTop in class GridView

setCacheSize

public void setCacheSize(int cacheSize)
Sets the amount of rows that should be cached (default to 200). The cache size is the number of rows that are retrieved each time a data request is made. The cache size should always be greater than the number of visible rows of the grid. The number of visible rows will vary depending on the grid height and the height of each row. If the set cache size is smaller than the number of visible rows of the grid than it gets set to the number of visible rows of the grid.

Parameters:
cacheSize - the new cache size

setLoadDelay

public void setLoadDelay(int loadDelay)
Sets the amount of time before loading is done (defaults to 200).

Parameters:
loadDelay - the new load delay in milliseconds

setPrefetchFactor

public void setPrefetchFactor(double prefetchFactor)
Sets the pre-fetch factor (defaults to .2). The pre-fetch factor is used to determine when new data should be fetched as the user scrolls the grid. The factor is used with the cache size.

For example, if the cache size is 1000 with a pre-fetch of .20, the grid will request new data when the 800th (1000 * .20) row of the grid becomes visible.

Parameters:
prefetchFactor - the pre-fetch factor

setRowHeight

public void setRowHeight(int rowHeight)
Sets the height of one row (defaults to 20). LiveGridView will only work with fixed row heights with all rows being the same height. Changing this value will not physically resize the row heights, rather, the specified height will be used internally for calculations.

Parameters:
rowHeight - the new row height.

afterRender

protected void afterRender()
Overrides:
afterRender in class GridView

calculateVBar

protected void calculateVBar(boolean force)
Overrides:
calculateVBar in class GridView

createComponentEvent

protected GridEvent<?> createComponentEvent(com.google.gwt.user.client.Event event)
Overrides:
createComponentEvent in class GridView

doLoad

protected void doLoad()

getCalculatedRowHeight

protected int getCalculatedRowHeight()

getLiveScrollerHeight

protected int getLiveScrollerHeight()

getLiveStoreCalculatedIndex

protected int getLiveStoreCalculatedIndex(int index)

getScrollAdjust

protected int getScrollAdjust()
Overrides:
getScrollAdjust in class GridView

initData

protected void initData(ListStore ds,
                        ColumnModel cm)
Description copied from class: GridView
Initializes the data.

Overrides:
initData in class GridView
Parameters:
ds - the data store
cm - the column model

isCached

protected boolean isCached(int index)

isHorizontalScrollBarShowing

protected boolean isHorizontalScrollBarShowing()

loadLiveStore

protected boolean loadLiveStore(int offset)

notifyShow

protected void notifyShow()
Overrides:
notifyShow in class GridView

onColumnWidthChange

protected void onColumnWidthChange(int column,
                                   int width)
Overrides:
onColumnWidthChange in class GridView

onRemove

protected void onRemove(ListStore<ModelData> ds,
                        ModelData m,
                        int index,
                        boolean isUpdate)
Overrides:
onRemove in class GridView

renderUI

protected void renderUI()
Overrides:
renderUI in class GridView

resize

protected void resize()
Overrides:
resize in class GridView

shouldCache

protected boolean shouldCache(int index)

updateRows

protected void updateRows(int newIndex,
                          boolean reload)