com.sencha.gxt.widget.core.client.grid
Class GridView<M>

java.lang.Object
  extended by com.sencha.gxt.widget.core.client.grid.GridView<M>
Direct Known Subclasses:
GroupingView, LiveGridView, TreeGridView

public class GridView<M>
extends java.lang.Object

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 a ListStore.


Nested Class Summary
static interface GridView.GridAppearance
          Define the appearance of a Grid.
static interface GridView.GridDataTableStyles
           
static interface GridView.GridStyles
           
static interface GridView.GridTemplates
           
 
Constructor Summary
GridView()
          Creates a new grid view.
GridView(GridView.GridAppearance appearance)
          Creates a new grid view.
 
Method Summary
 Point ensureVisible(int row, int col, boolean hscroll)
          Ensured the current row and column is visible.
 Element findCell(Element elem)
          Returns the cell.
 int findCellIndex(Element elem, java.lang.String requiredStyle)
          Returns the cell index.
 Element findRow(Element elem)
          Returns the row element.
 int findRowIndex(Element elem)
          Returns the row index.
 void focus()
          Focuses the grid.
 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.
 GridView.GridAppearance getAppearance()
          Returns the grid appearance.
 ColumnConfig<M,?> getAutoExpandColumn()
          Returns the auto expand column id.
 int getAutoExpandMax()
          Returns the auto expand maximum width.
 int getAutoExpandMin()
          Returns the auto expand minimum width.
 XElement getBody()
          Returns the body element.
 Element getCell(int row, int col)
          Returns the grid's <TD> HtmlElement at the specified coordinates.
 Element getEditorParent()
          Returns the editor parent element.
 java.lang.String getEmptyText()
          Returns the empty text.
 ColumnHeader<M> getHeader()
          Returns the grid's column header.
 Element getRow(int row)
          Return the <TR> HtmlElement which represents a Grid row for the specified index.
 Element getRow(M m)
          Return the <TR> HtmlElement which represents a Grid row for the specified model.
 Element getRowBody(Element row)
           
 int getRowBodyRowSpan()
          Returns the number of rows the first column should span when row bodies have been enabled.
 XElement getScroller()
          Returns the scroll element.
 Point getScrollState()
          Returns the current scroll state.
 GridViewConfig<M> getViewConfig()
          Returns the view config.
 boolean isAdjustForHScroll()
          Returns true if the grid width will be adjusted based on visibility of horizontal scroll bar.
 boolean isAutoFill()
          Returns true if auto fill is enabled.
 boolean isColumnLines()
          Returns true if column lines are enabled.
 boolean isDeferUpdates()
          Returns true if rows are updated deferred on updates.
 boolean isEnableRowBody()
          Returns true if row bodies are enabled.
 boolean isForceFit()
          Returns true if force fit is enabled.
 boolean isSelectableTarget(Element target)
          Returns true if the given element is selectable.
 boolean isShowDirtyCells()
          Returns true if dirty cell markers are enabled.
 boolean isSortingEnabled()
          Returns true if sorting is enabled.
 boolean isStripeRows()
          Returns true if row striping is enabled.
 boolean isTrackMouseOver()
          Returns true if rows are highlighted on mouse over.
 void layout()
          Lays out the grid view, adjusting the header and footer width and accounting for force fit and auto fill settings.
 void refresh(boolean headerToo)
          Rebuilds the grid using its current configuration and data.
 void scrollToTop()
          Scrolls the grid to the top.
 void setAdjustForHScroll(boolean adjustForHScroll)
          True to adjust the grid width when the horizontal scrollbar is hidden and visible (defaults to true).
 void setAutoExpandColumn(ColumnConfig<M,?> autoExpandColumn)
          The id of a column in this grid that should expand to fill unused space (pre-render).
 void setAutoExpandMax(int autoExpandMax)
          The maximum width the autoExpandColumn can have (if enabled) (defaults to 500, pre-render).
 void setAutoExpandMin(int autoExpandMin)
          The minimum width the autoExpandColumn can have (if enabled)(pre-render).
 void setAutoFill(boolean autoFill)
          True to auto expand the columns to fit the grid when the grid is created.
 void setColumnLines(boolean columnLines)
          True to enable column separation lines (defaults to false).
 void setDeferUpdates(boolean deferUpdates)
          True to update rows deferred (defaults to false).
 void setEmptyText(java.lang.String emptyText)
          Default text to display in the grid body when no rows are available (defaults to '').
 void setEnableRowBody(boolean enableRowBody)
          True to enable a column spanning row body, as used by RowExpander (defaults to false).
 void setForceFit(boolean forceFit)
          True to auto expand/contract the size of the columns to fit the grid width and prevent horizontal scrolling.
 void setRowBodyRowSpan(int rowBodyRowSpan)
          Sets the rowspan the first column should span when row bodies have been enabled (defaults to 1).
 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 setStripeRows(boolean stripeRows)
          True to stripe the rows (defaults to false).
 void setTrackMouseOver(boolean trackMouseOver)
          True to highlight rows when the mouse is over (defaults to true).
 void setViewConfig(GridViewConfig<M> viewConfig)
          Sets the view config.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridView

public GridView()
Creates a new grid view.


GridView

public GridView(GridView.GridAppearance appearance)
Creates a new grid view.

Parameters:
appearance - the grid appearance
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 Element findCell(Element elem)
Returns the cell.

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

findCellIndex

public int findCellIndex(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 Element findRow(Element elem)
Returns the row element.

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

findRowIndex

public int findRowIndex(Element elem)
Returns the row index.

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

focus

public void focus()
Focuses the grid.


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

getAppearance

public GridView.GridAppearance getAppearance()
Returns the grid appearance.

Returns:
the grid appearance

getAutoExpandColumn

public ColumnConfig<M,?> getAutoExpandColumn()
Returns the auto expand column id.

Returns:
the auto expand column id

getAutoExpandMax

public int getAutoExpandMax()
Returns the auto expand maximum width.

Returns:
the max width in pixels

getAutoExpandMin

public int getAutoExpandMin()
Returns the auto expand minimum width.

Returns:
the minimum width in pixels

getBody

public XElement getBody()
Returns the body element.

Returns:
the body element

getCell

public 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

getEditorParent

public 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<M> getHeader()
Returns the grid's column header.

Returns:
the header

getRow

public 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 Element getRow(M m)
Return the <TR> HtmlElement which represents a Grid row for the specified model.

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

getRowBody

public Element getRowBody(Element row)

getRowBodyRowSpan

public int getRowBodyRowSpan()
Returns the number of rows the first column should span when row bodies have been enabled.

Returns:
the rowspan

getScroller

public XElement getScroller()
Returns the scroll element.

Returns:
the scroll element

getScrollState

public Point getScrollState()
Returns the current scroll state.

Returns:
the scroll state

getViewConfig

public GridViewConfig<M> getViewConfig()
Returns the view config.

Returns:
the view config

isAdjustForHScroll

public boolean isAdjustForHScroll()
Returns true if the grid width will be adjusted based on visibility of horizontal scroll bar.

Returns:
true if adjusting

isAutoFill

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

Returns:
true for auto fill

isColumnLines

public boolean isColumnLines()
Returns true if column lines are enabled.

Returns:
true if column lines are enabled

isDeferUpdates

public boolean isDeferUpdates()
Returns true if rows are updated deferred on updates.

Returns:
true if updates deferred

isEnableRowBody

public boolean isEnableRowBody()
Returns true if row bodies are enabled.

Returns:
true for row bodies

isForceFit

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

Returns:
true for force fit

isSelectableTarget

public boolean isSelectableTarget(Element target)
Returns true if the given element is selectable.

Parameters:
target - the element to check
Returns:
true if the given element is selectable

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

isStripeRows

public boolean isStripeRows()
Returns true if row striping is enabled.

Returns:
the strip row state

isTrackMouseOver

public boolean isTrackMouseOver()
Returns true if rows are highlighted on mouse over.

Returns:
the track mouse state

layout

public void layout()
Lays out the grid view, adjusting the header and footer width and accounting for force fit and auto fill settings.


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.


setAdjustForHScroll

public void setAdjustForHScroll(boolean adjustForHScroll)
True to adjust the grid width when the horizontal scrollbar is hidden and visible (defaults to true).

Parameters:
adjustForHScroll - true to adjust for horizontal scroll bar

setAutoExpandColumn

public void setAutoExpandColumn(ColumnConfig<M,?> autoExpandColumn)
The id of a column in this grid that should expand to fill unused space (pre-render). This id can not be 0.

Parameters:
autoExpandColumn - the auto expand column

setAutoExpandMax

public void setAutoExpandMax(int autoExpandMax)
The maximum width the autoExpandColumn can have (if enabled) (defaults to 500, pre-render).

Parameters:
autoExpandMax - the auto expand max

setAutoExpandMin

public void setAutoExpandMin(int autoExpandMin)
The minimum width the autoExpandColumn can have (if enabled)(pre-render).

Parameters:
autoExpandMin - the auto expand min width

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

setColumnLines

public void setColumnLines(boolean columnLines)
True to enable column separation lines (defaults to false).

Parameters:
columnLines - true to enable column separation lines

setDeferUpdates

public void setDeferUpdates(boolean deferUpdates)
True to update rows deferred (defaults to false).

Parameters:
deferUpdates - true to update deferred

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

setEnableRowBody

public void setEnableRowBody(boolean enableRowBody)
True to enable a column spanning row body, as used by RowExpander (defaults to false).

Parameters:
enableRowBody - true to enable row bodies

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

setRowBodyRowSpan

public void setRowBodyRowSpan(int rowBodyRowSpan)
Sets the rowspan the first column should span when row bodies have been enabled (defaults to 1).

Parameters:
rowBodyRowSpan - the rowspan

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

setStripeRows

public void setStripeRows(boolean stripeRows)
True to stripe the rows (defaults to false).

Parameters:
stripeRows - true to strip rows

setTrackMouseOver

public void setTrackMouseOver(boolean trackMouseOver)
True to highlight rows when the mouse is over (defaults to true).

Parameters:
trackMouseOver - true to highlight rows on mouse over

setViewConfig

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

Parameters:
viewConfig - the view config


Copyright © 2012. All Rights Reserved.