T
- the data type of each rowpublic class DataGrid<T> extends AbstractCellTable<T> implements RequiresResize
Column
class defines the
Cell
used to render a column. Implement
Column.getValue(Object)
to retrieve the field value from the row
object that will be rendered in the Cell
.
Header
can be placed at the top
(header) or bottom (footer) of the DataGrid
. You can specify a header
as text using AbstractCellTable.addColumn(Column, String)
, or you can create a custom
Header
that can change with the value of the cells, such as a column
total. The Header
will be rendered every time the row data changes or
the table is redrawn. If you pass the same header instance (==) into adjacent
columns, the header will span the columns.
Modifier and Type | Class and Description |
---|---|
static interface |
DataGrid.Resources
A ClientBundle that provides images for this widget.
|
static interface |
DataGrid.Style
Styles used by this widget.
|
AbstractCellTable.CellTableKeyboardSelectionHandler<T>, AbstractCellTable.TableSectionChangeHandler
AbstractHasData.DefaultKeyboardSelectionHandler<T>
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
HasKeyboardPagingPolicy.KeyboardPagingPolicy
HasKeyboardSelectionPolicy.KeyboardSelectionPolicy
DEBUG_ID_PREFIX
Constructor and Description |
---|
DataGrid()
Constructs a table with a default page size of 50.
|
DataGrid(int pageSize)
Constructs a table with the given page size.
|
DataGrid(int pageSize,
DataGrid.Resources resources)
Constructs a table with the given page size with the specified
DataGrid.Resources . |
DataGrid(int pageSize,
DataGrid.Resources resources,
ProvidesKey<T> keyProvider)
Constructs a table with the given page size, the specified
DataGrid.Resources , and the given key provider. |
DataGrid(int pageSize,
DataGrid.Resources resources,
ProvidesKey<T> keyProvider,
Widget loadingIndicator)
Constructs a table with the given page size, the specified
DataGrid.Resources , and the given key provider. |
DataGrid(int pageSize,
ProvidesKey<T> keyProvider)
Constructs a table with the given page size and the given
key provider . |
DataGrid(ProvidesKey<T> keyProvider)
Constructs a table with a default page size of 50, and the given
key provider . |
Modifier and Type | Method and Description |
---|---|
void |
addColumnStyleName(int index,
String styleName)
Add a style name to the
col element at the specified index,
creating it if necessary. |
void |
clearTableWidth()
Clear the width of the tables in this widget, which causes them to fill the
available width.
|
protected void |
doSetColumnWidth(int column,
String width)
Set the width of a column.
|
protected void |
doSetHeaderVisible(boolean isFooter,
boolean isVisible)
Show or hide a header section.
|
protected TableSectionElement |
getTableBodyElement()
Get the tbody element that contains the render row values.
|
protected TableSectionElement |
getTableFootElement()
Get the tfoot element that contains the footers.
|
protected TableSectionElement |
getTableHeadElement()
Get the thead element that contains the headers.
|
protected void |
onLoadingStateChanged(LoadingStateChangeEvent.LoadingState state)
Called when the loading state changes.
|
void |
onResize()
This method must be called whenever the implementor's size has been
modified.
|
protected void |
refreshColumnWidths() |
void |
removeColumnStyleName(int index,
String styleName)
Remove a style from the
col element at the specified index. |
void |
setAlwaysShowScrollBars(boolean alwaysShowScrollBars)
Sets whether this grid always shows its scroll bars, or only when necessary.
|
void |
setEmptyTableWidget(Widget widget)
Set the widget to display when the table has no rows.
|
void |
setLoadingIndicator(Widget widget)
Set the widget to display when the data is loading.
|
void |
setMinimumTableWidth(double value,
Style.Unit unit)
Set the minimum width of the tables in this widget.
|
void |
setTableWidth(double value,
Style.Unit unit)
Set the width of the tables in this widget.
|
addColumn, addColumn, addColumn, addColumn, addColumn, addColumn, addColumn, addColumnSortHandler, addRowHoverHandler, clearColumnWidth, clearColumnWidth, convertToElements, dependsOnSelection, flush, getChildContainer, getChildElement, getColumn, getColumnCount, getColumnIndex, getColumnSortList, getColumnWidth, getEmptyTableWidget, getFooter, getFooterBuilder, getHeader, getHeaderBuilder, getKeyboardSelectedColumn, getKeyboardSelectedElement, getKeyboardSelectedSubRow, getLoadingIndicator, getRealColumnCount, getResources, getRowElement, getRowStyles, getSubRowElement, insertColumn, insertColumn, insertColumn, insertColumn, insertColumn, insertColumn, insertColumn, isAutoFooterRefreshDisabled, isAutoHeaderRefreshDisabled, isKeyboardNavigationSuppressed, isSkipRowHoverCheck, isSkipRowHoverFloatElementCheck, isSkipRowHoverStyleUpdate, onBlur, onBrowserEvent2, onFocus, redrawFooters, redrawHeaders, removeColumn, removeColumn, renderRowValues, renderRowValuesLegacy, replaceAllChildren, replaceChildren, resetFocusOnCell, setAutoFooterRefreshDisabled, setAutoHeaderRefreshDisabled, setColumnWidth, setColumnWidth, setColumnWidth, setColumnWidth, setFooterBuilder, setHeaderBuilder, setKeyboardSelected, setKeyboardSelectedColumn, setKeyboardSelectedColumn, setKeyboardSelectedRow, setKeyboardSelectedRow, setRowStyles, setSkipRowHoverCheck, setSkipRowHoverFloatElementCheck, setSkipRowHoverStyleUpdate, setTableBuilder
addCellPreviewHandler, addLoadingStateChangeHandler, addRangeChangeHandler, addRowCountChangeHandler, cellConsumesEventType, checkRowBounds, getAccessKey, getDisplayedItem, getDisplayedItems, getKeyboardPagingPolicy, getKeyboardSelectedRow, getKeyboardSelectionPolicy, getKeyProvider, getPageSize, getPageStart, getRowContainer, getRowCount, getSelectionModel, getTabIndex, getValueKey, getVisibleItem, getVisibleItemCount, getVisibleItems, getVisibleRange, isRowCountExact, isRowWithinBounds, onBrowserEvent, onUnload, redraw, redrawRow, setAccessKey, setFocus, setFocusable, setKeyboardPagingPolicy, setKeyboardSelectedRow, setKeyboardSelectionHandler, setKeyboardSelectionPolicy, setPageSize, setPageStart, setRowCount, setRowCount, setRowData, setRowData, setSelected, setSelectionModel, setSelectionModel, setTabIndex, setVisibleRange, setVisibleRange, setVisibleRangeAndClearData
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onDetach, render, render, resolvePotentialElement, setWidget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
fireEvent
public DataGrid()
public DataGrid(int pageSize)
pageSize
- the page sizepublic DataGrid(int pageSize, ProvidesKey<T> keyProvider)
key provider
.pageSize
- the page sizekeyProvider
- an instance of ProvidesKeypublic DataGrid(int pageSize, DataGrid.Resources resources)
DataGrid.Resources
.pageSize
- the page sizeresources
- the resources to use for this widgetpublic DataGrid(int pageSize, DataGrid.Resources resources, ProvidesKey<T> keyProvider)
DataGrid.Resources
, and the given key provider.pageSize
- the page sizeresources
- the resources to use for this widgetkeyProvider
- an instance of ProvidesKeypublic DataGrid(int pageSize, DataGrid.Resources resources, ProvidesKey<T> keyProvider, Widget loadingIndicator)
DataGrid.Resources
, and the given key provider.pageSize
- the page sizeresources
- the resources to use for this widgetkeyProvider
- an instance of ProvidesKeyloadingIndicator
- the widget to use as a loading indicator, or null
to disablepublic DataGrid(ProvidesKey<T> keyProvider)
key provider
.keyProvider
- an instance of ProvidesKeypublic void addColumnStyleName(int index, String styleName)
AbstractCellTable
col
element at the specified index,
creating it if necessary.addColumnStyleName
in class AbstractCellTable<T>
index
- the column indexstyleName
- the style name to addpublic void clearTableWidth()
The table width is not the same as the width of this widget. If the tables are narrower than this widget, there will be a gap between the table and the edge of the widget. If the tables are wider than this widget, a horizontal scrollbar will appear so the user can scroll horizontally.
#setMinimumTableWidth(double, Unit)
,
#setTableWidth(double, Unit)
public void onResize()
RequiresResize
onResize
in interface RequiresResize
public void removeColumnStyleName(int index, String styleName)
AbstractCellTable
col
element at the specified index.removeColumnStyleName
in class AbstractCellTable<T>
index
- the column indexstyleName
- the style name to removepublic void setAlwaysShowScrollBars(boolean alwaysShowScrollBars)
alwaysShowScrollBars
- true
to show scroll bars at all timespublic void setEmptyTableWidget(Widget widget)
AbstractCellTable
setEmptyTableWidget
in class AbstractCellTable<T>
widget
- the empty table widget, or null to disablepublic void setLoadingIndicator(Widget widget)
AbstractCellTable
setLoadingIndicator
in class AbstractCellTable<T>
widget
- the loading indicator, or null to disablepublic void setMinimumTableWidth(double value, Style.Unit unit)
Note that this method is not supported in IE6 and earlier versions of IE.
value
- the widthunit
- the unit of the width#setTableWidth(double, Unit)
public void setTableWidth(double value, Style.Unit unit)
The table width is not the same as the width of this widget. If the tables are narrower than this widget, there will be a gap between the table and the edge of the widget. If the tables are wider than this widget, a horizontal scrollbar will appear so the user can scroll horizontally.
If your table has many columns and you want to ensure that the columns are
not truncated, you probably want to use
#setMinimumTableWidth(double, Unit)
instead. That will ensure that
the table is wide enough, but it will still allow the table to expand to
100% if the user has a wide screen.
Note that setting the width in percentages will not work on older versions of IE because it does not account for scrollbars when calculating the width.
value
- the widthunit
- the unit of the width#setMinimumTableWidth(double, Unit)
protected void doSetColumnWidth(int column, String width)
AbstractCellTable
doSetColumnWidth
in class AbstractCellTable<T>
column
- the column indexwidth
- the width, or null to clear the widthprotected void doSetHeaderVisible(boolean isFooter, boolean isVisible)
AbstractCellTable
doSetHeaderVisible
in class AbstractCellTable<T>
isFooter
- true for the footer, false for the headerisVisible
- true to show, false to hideprotected TableSectionElement getTableBodyElement()
AbstractCellTable
getTableBodyElement
in class AbstractCellTable<T>
protected TableSectionElement getTableFootElement()
AbstractCellTable
getTableFootElement
in class AbstractCellTable<T>
protected TableSectionElement getTableHeadElement()
AbstractCellTable
getTableHeadElement
in class AbstractCellTable<T>
protected void onLoadingStateChanged(LoadingStateChangeEvent.LoadingState state)
onLoadingStateChanged
in class AbstractHasData<T>
state
- the new loading stateprotected void refreshColumnWidths()
refreshColumnWidths
in class AbstractCellTable<T>
Copyright © 2016. All rights reserved.