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

java.lang.Object
  extended by com.extjs.gxt.ui.client.event.BaseObservable
      extended by com.extjs.gxt.ui.client.widget.grid.GridView
All Implemented Interfaces:
Observable
Direct Known Subclasses:
BufferView, GroupingView

public class GridView
extends BaseObservable

This class encapsulates the user interface of an Grid. Methods of this class may be used to access user interface elements to enable special display effects. Do not change the DOM structure of the user interface.

This class does not provide ways to manipulate the underlying data. The data model of a Grid is held in an ListStore.


Nested Class Summary
 class GridView.GridViewImages
          Icons used by Grid which can be overridden as needed.
 
Constructor Summary
GridView()
           
 
Method Summary
 Point ensureVisible(int row, int col, boolean hscroll)
          Ensured the current row and column is visible.
 com.google.gwt.dom.client.Element findCell(com.google.gwt.dom.client.Element elem)
          Returns the cell.
 int findCellIndex(com.google.gwt.dom.client.Element elem, java.lang.String requiredStyle)
          Returns the cell index.
 com.google.gwt.dom.client.Element findRow(com.google.gwt.dom.client.Element el)
          Returns the row element.
 int findRowIndex(com.google.gwt.dom.client.Element elem)
          Returns the row index.
 void focusCell(int rowIndex, int colIndex, boolean hscroll)
          Focus the cell and scrolls into view.
 void focusRow(int rowIndex)
          Focus the row and scrolls into view.
 El getBody()
          Returns the grid's body element.
 com.google.gwt.dom.client.Element getCell(int row, int col)
          Returns the grid's <TD> HtmlElement at the specified coordinates.
 int getCellSelectorDepth()
          Returns the cell selector depth.
 com.google.gwt.dom.client.Element getEditorParent()
          Returns the editor parent element.
 java.lang.String getEmptyText()
          Returns the empty text.
 ColumnHeader getHeader()
          Returns the grid's column header.
 com.google.gwt.dom.client.Element getHeaderCell(int index)
          Returns the <TD> HtmlElement which represents the Grid's header cell for the specified column index.
 GridView.GridViewImages getImages()
          Returns the images used by grid.
 com.google.gwt.dom.client.Element getRow(int row)
          Return the <TR> HtmlElement which represents a Grid row for the specified index.
 com.google.gwt.dom.client.Element getRow(ModelData m)
          Return the <TR> HtmlElement which represents a Grid row for the specified model.
 int getRowSelectorDepth()
          Returns the row selector depth.
 Point getScrollState()
          Returns the current scroll state.
 GridViewConfig getViewConfig()
          Returns the view config.
 com.google.gwt.user.client.ui.Widget getWidget(int rowIndex, int colIndex)
          Returns the widget at the current location.
 boolean isAutoFill()
          Returns true if auto fill is enabled.
 boolean isForceFit()
          Returns true if force fit is enabled.
 boolean isShowDirtyCells()
          Returns true if dirty cell markers are enabled.
 boolean isSortingEnabled()
          Returns true if sorting is enabled.
 void layout()
           
 void refresh(boolean headerToo)
          Rebuilds the grid using its current configuration and data.
 void scrollToTop()
          Scrolls the grid to the top.
 void setAutoFill(boolean autoFill)
          True to auto expand the columns to fit the grid when the grid is created.
 void setCellSelectorDepth(int cellSelectorDepth)
          The number of levels to search for cells in event delegation (defaults to 4).
 void setEmptyText(java.lang.String emptyText)
          Default text to display in the grid body when no rows are available (defaults to '').
 void setForceFit(boolean forceFit)
          True to auto expand/contract the size of the columns to fit the grid width and prevent horizontal scrolling.
 void setRowSelectorDepth(int rowSelectorDepth)
          The number of levels to search for rows in event delegation (defaults to 10).
 void setShowDirtyCells(boolean showDirtyCells)
          True to display a red triangle in the upper left corner of any cells which are "dirty" as defined by any existing records in the data store (defaults to true).
 void setSortingEnabled(boolean sortable)
          True to allow column sorting when the user clicks a column (defaults to true).
 void setViewConfig(GridViewConfig viewConfig)
          Sets the view config.
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, fireEvent, fireEvent, getFiresEvents, getListeners, hasActiveEvent, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridView

public GridView()
Method Detail

ensureVisible

public Point ensureVisible(int row,
                           int col,
                           boolean hscroll)
Ensured the current row and column is visible.

Parameters:
row - the row index
col - the column index
hscroll - true to scroll horizontally if needed
Returns:
the calculated point

findCell

public com.google.gwt.dom.client.Element findCell(com.google.gwt.dom.client.Element elem)
Returns the cell.

Parameters:
elem - the cell element or a child element
Returns:
the cell element

findCellIndex

public int findCellIndex(com.google.gwt.dom.client.Element elem,
                         java.lang.String requiredStyle)
Returns the cell index.

Parameters:
elem - the cell or child element
requiredStyle - an optional required style name
Returns:
the cell index or -1 if not found

findRow

public com.google.gwt.dom.client.Element findRow(com.google.gwt.dom.client.Element el)
Returns the row element.

Parameters:
el - the row element or any child element
Returns:
the matching row element

findRowIndex

public int findRowIndex(com.google.gwt.dom.client.Element elem)
Returns the row index.

Parameters:
elem - the row or child of the row element
Returns:
the index

focusCell

public void focusCell(int rowIndex,
                      int colIndex,
                      boolean hscroll)
Focus the cell and scrolls into view.

Parameters:
rowIndex - the row index
colIndex - the column index
hscroll - true to scroll horizontally

focusRow

public void focusRow(int rowIndex)
Focus the row and scrolls into view.

Parameters:
rowIndex - the row index

getBody

public El getBody()
Returns the grid's body element.

Returns:
the body element

getCell

public com.google.gwt.dom.client.Element getCell(int row,
                                                 int col)
Returns the grid's <TD> HtmlElement at the specified coordinates.

Parameters:
row - the row index in which to find the cell
col - the column index of the cell
Returns:
the <TD> at the specified coordinates

getCellSelectorDepth

public int getCellSelectorDepth()
Returns the cell selector depth.

Returns:
the cell selector depth

getEditorParent

public com.google.gwt.dom.client.Element getEditorParent()
Returns the editor parent element.

Returns:
the editor element

getEmptyText

public java.lang.String getEmptyText()
Returns the empty text.

Returns:
the empty text

getHeader

public ColumnHeader getHeader()
Returns the grid's column header.

Returns:
the header

getHeaderCell

public com.google.gwt.dom.client.Element getHeaderCell(int index)
Returns the <TD> HtmlElement which represents the Grid's header cell for the specified column index.

Parameters:
index - the column index
Returns:
the <TD> element.

getImages

public GridView.GridViewImages getImages()
Returns the images used by grid.

Returns:
the images

getRow

public com.google.gwt.dom.client.Element getRow(int row)
Return the <TR> HtmlElement which represents a Grid row for the specified index.

Parameters:
row - the row index
Returns:
the <TR> element

getRow

public com.google.gwt.dom.client.Element getRow(ModelData m)
Return the <TR> HtmlElement which represents a Grid row for the specified model.

Parameters:
m - the model
Returns:
the <TR> element

getRowSelectorDepth

public int getRowSelectorDepth()
Returns the row selector depth.

Returns:
the row selector depth

getScrollState

public Point getScrollState()
Returns the current scroll state.

Returns:
the scroll state

getViewConfig

public GridViewConfig getViewConfig()
Returns the view config.

Returns:
the view config

getWidget

public com.google.gwt.user.client.ui.Widget getWidget(int rowIndex,
                                                      int colIndex)
Returns the widget at the current location.

Parameters:
rowIndex - the row index
colIndex - the column index
Returns:
the widget or null

isAutoFill

public boolean isAutoFill()
Returns true if auto fill is enabled.

Returns:
true for auto fill

isForceFit

public boolean isForceFit()
Returns true if force fit is enabled.

Returns:
true for force fit

isShowDirtyCells

public boolean isShowDirtyCells()
Returns true if dirty cell markers are enabled.

Returns:
true of dirty cell markers

isSortingEnabled

public boolean isSortingEnabled()
Returns true if sorting is enabled.

Returns:
true for sorting

layout

public void layout()

refresh

public void refresh(boolean headerToo)
Rebuilds the grid using its current configuration and data.

Parameters:
headerToo - true to refresh the header

scrollToTop

public void scrollToTop()
Scrolls the grid to the top.


setAutoFill

public void setAutoFill(boolean autoFill)
True to auto expand the columns to fit the grid when the grid is created.

Parameters:
autoFill - true to expand

setCellSelectorDepth

public void setCellSelectorDepth(int cellSelectorDepth)
The number of levels to search for cells in event delegation (defaults to 4).

Parameters:
cellSelectorDepth - the cell selector depth

setEmptyText

public void setEmptyText(java.lang.String emptyText)
Default text to display in the grid body when no rows are available (defaults to '').

Parameters:
emptyText - the empty text

setForceFit

public void setForceFit(boolean forceFit)
True to auto expand/contract the size of the columns to fit the grid width and prevent horizontal scrolling.

Parameters:
forceFit - true to force fit

setRowSelectorDepth

public void setRowSelectorDepth(int rowSelectorDepth)
The number of levels to search for rows in event delegation (defaults to 10).

Parameters:
rowSelectorDepth - the row selector depth

setShowDirtyCells

public void setShowDirtyCells(boolean showDirtyCells)
True to display a red triangle in the upper left corner of any cells which are "dirty" as defined by any existing records in the data store (defaults to true).

Parameters:
showDirtyCells - true to display the dirty flag

setSortingEnabled

public void setSortingEnabled(boolean sortable)
True to allow column sorting when the user clicks a column (defaults to true).

Parameters:
sortable - true for sortable columns

setViewConfig

public void setViewConfig(GridViewConfig viewConfig)
Sets the view config.

Parameters:
viewConfig - the view config