public class GridView<M> extends Object
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
.Modifier and Type | Class and Description |
---|---|
static interface |
GridView.GridAppearance
Define the appearance of a Grid.
|
static interface |
GridView.GridStateStyles
Marker classes, used only to indicate state and landmark details in the dom.
|
static interface |
GridView.GridStyles |
static interface |
GridView.GridTemplates |
Constructor and Description |
---|
GridView()
Creates a new grid view.
|
GridView(GridView.GridAppearance appearance)
Creates a new grid view.
|
Modifier and Type | Method and Description |
---|---|
<H extends EventHandler> |
addHandler(GwtEvent.Type<H> type,
H handler)
Adds a handler to receive specific events from this object.
|
Point |
ensureVisible(int row,
int col,
boolean hscroll)
Ensured the current row and column is visible.
|
Point |
ensureVisible(M model)
Ensures the given model (row) is visible.
|
Element |
findCell(Element elem)
Returns the cell.
|
int |
findCellIndex(Element elem,
String requiredStyle)
Returns the cell index.
|
Element |
findRow(Element elem)
Returns the row element.
|
int |
findRowIndex(Element elem)
Returns the row index.
|
void |
fireEvent(GwtEvent<?> event)
Fires the given event from this object as its source.
|
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.
|
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.
|
Store.StoreSortInfo<M> |
getSortState()
Returns the grid's sort information.
|
GridView.GridStateStyles |
getStateStyles() |
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 |
scrollToTop(boolean resetHorizontal)
Scrolls the grid 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 |
setColumnHeader(ColumnHeader<M> columnHeader) |
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(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
(defaults to false).
|
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.
|
public GridView()
public GridView(GridView.GridAppearance appearance)
appearance
- the grid appearancepublic <H extends EventHandler> HandlerRegistration addHandler(GwtEvent.Type<H> type, H handler)
H
- the handler typetype
- the type of event to listen forhandler
- the handler to call when the event occurspublic Point ensureVisible(M model)
model
- the target modelpublic Point ensureVisible(int row, int col, boolean hscroll)
row
- the row indexcol
- the column indexhscroll
- true to scroll horizontally if neededpublic Element findCell(Element elem)
elem
- the cell element or a child elementpublic int findCellIndex(Element elem, String requiredStyle)
elem
- the cell or child elementrequiredStyle
- an optional required style namepublic Element findRow(Element elem)
elem
- the row element or any child elementpublic int findRowIndex(Element elem)
elem
- the row or child of the row elementpublic void fireEvent(GwtEvent<?> event)
event
- the event to firepublic void focus()
public void focusCell(int rowIndex, int colIndex, boolean hscroll)
rowIndex
- the row indexcolIndex
- the column indexhscroll
- true to scroll horizontallypublic void focusRow(int rowIndex)
rowIndex
- the row indexpublic GridView.GridAppearance getAppearance()
public ColumnConfig<M,?> getAutoExpandColumn()
public int getAutoExpandMax()
public int getAutoExpandMin()
public XElement getBody()
public Element getCell(int row, int col)
row
- the row index in which to find the cellcol
- the column index of the cellpublic Element getEditorParent()
public String getEmptyText()
public ColumnHeader<M> getHeader()
public Element getRow(int row)
row
- the row indexpublic Element getRow(M m)
m
- the modelpublic int getRowBodyRowSpan()
public XElement getScroller()
public Point getScrollState()
public Store.StoreSortInfo<M> getSortState()
public GridView.GridStateStyles getStateStyles()
public GridViewConfig<M> getViewConfig()
public boolean isAdjustForHScroll()
public boolean isAutoFill()
public boolean isColumnLines()
public boolean isDeferUpdates()
public boolean isEnableRowBody()
public boolean isForceFit()
public boolean isSelectableTarget(Element target)
target
- the element to checkpublic boolean isShowDirtyCells()
public boolean isSortingEnabled()
public boolean isStripeRows()
public boolean isTrackMouseOver()
public void layout()
public void refresh(boolean headerToo)
headerToo
- true to refresh the headerpublic void scrollToTop()
public void scrollToTop(boolean resetHorizontal)
resetHorizontal
- true to reset horizontalpublic void setAdjustForHScroll(boolean adjustForHScroll)
adjustForHScroll
- true to adjust for horizontal scroll barpublic void setAutoExpandColumn(ColumnConfig<M,?> autoExpandColumn)
autoExpandColumn
- the auto expand columnpublic void setAutoExpandMax(int autoExpandMax)
autoExpandMax
- the auto expand maxpublic void setAutoExpandMin(int autoExpandMin)
autoExpandMin
- the auto expand min widthpublic void setAutoFill(boolean autoFill)
autoFill
- true to expandpublic void setColumnLines(boolean columnLines)
columnLines
- true to enable column separation linespublic void setDeferUpdates(boolean deferUpdates)
deferUpdates
- true to update deferredpublic void setEmptyText(String emptyText)
emptyText
- the empty textpublic void setEnableRowBody(boolean enableRowBody)
RowExpander
(defaults to false).enableRowBody
- true to enable row bodiespublic void setForceFit(boolean forceFit)
forceFit
- true to force fitpublic void setRowBodyRowSpan(int rowBodyRowSpan)
rowBodyRowSpan
- the rowspanpublic void setShowDirtyCells(boolean showDirtyCells)
showDirtyCells
- true to display the dirty flagpublic void setSortingEnabled(boolean sortable)
sortable
- true for sortable columnspublic void setStripeRows(boolean stripeRows)
stripeRows
- true to strip rowspublic void setTrackMouseOver(boolean trackMouseOver)
trackMouseOver
- true to highlight rows on mouse overpublic void setViewConfig(GridViewConfig<M> viewConfig)
viewConfig
- the view configpublic void setColumnHeader(ColumnHeader<M> columnHeader)
Copyright © 2015. All rights reserved.