|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WWidget
eu.webtoolkit.jwt.WCompositeWidget
eu.webtoolkit.jwt.WAbstractItemView
eu.webtoolkit.jwt.WTableView
public class WTableView
An MVC View widget for tabular data.
The view displays data from a WAbstractItemModel in a table. It
provides incremental rendering, without excessive use of client- or
serverside resources.
The rendering (and editing) of items is handled by a
WAbstractItemDelegate, by default it uses WItemDelegate which
renders data of all predefined roles (see also ItemDataRole),
including text, icons, checkboxes, and tooltips.
The view provides virtual scrolling in both horizontal and vertical directions, and can therefore be used to display large data models (with large number of columns and rows).
The view may support editing of items, if the model indicates support (see
the ItemFlag.ItemIsEditable flag). You can define triggers that
initiate editing of an item using
WAbstractItemView#setEditTriggers(). The actual editing is provided by the
item delegate (you can set an appropriate delegate for one column using
WAbstractItemView#setItemDelegateForColumn()). Using
WAbstractItemView#setEditOptions() you can customize if and how the view
deals with multiple editors.
By default, all columns are given a width of 150px. Column widths of all
columns can be set through the API method
setColumnWidth()
, and also by the user using handles provided in the header.
If the model supports sorting (
WAbstractItemModel#sort()), such as the WStandardItemModel, then you
can enable sorting buttons in the header, using
WAbstractItemView#setSortingEnabled().
You can allow selection on row or item level (using
WAbstractItemView#setSelectionBehavior()), and selection of single or
multiple items (using
WAbstractItemView#setSelectionMode()), and listen for changes in the
selection using the WAbstractItemView#selectionChanged() signal.
You may enable drag & drop support for this view, whith awareness of the
items in the model. When enabling dragging (see
WAbstractItemView#setDragEnabled()), the current selection may be dragged,
but only when all items in the selection indicate support for dragging
(controlled by the ItemIsDragEnabled
flag), and if the model indicates a mime-type (controlled by
WAbstractItemModel#getMimeType()).
Likewise, by enabling support for dropping (see
WAbstractItemView#setDropsEnabled()), the view may receive a drop event on a
particular item, at least if the item indicates support for drops (controlled
by the ItemIsDropEnabled flag).
You may also react to mouse click events on any item, by connecting to one of
the WAbstractItemView#clicked() or
WAbstractItemView#doubleClicked()
signals.
The tableview is styled by the current CSS theme. The look can be overridden
using the Wt-tableview CSS class and the following selectors.
Selectors that apply to the body:
.Wt-tableview .Wt-tv-contents : the main div used when javascript is available
.Wt-tableview .Wt-plaintable : the main table used when no javascript is
available
.Wt-tableview .Wt-pagingbar : the paging bar
.Wt-tableview .Wt-header : header background div
.Wt-tableview .Wt-headertable : div in the .Wt-header div to enable the
header scrolling
.Wt-tableview .Wt-label : header label
.Wt-tableview .Wt-tv-rh : column resize handle
.Wt-tableview .Wt-tv-sh-up : column sort handle, no sorting
.Wt-tableview .Wt-tv-sh-none : column sort handle, sort up
.Wt-tableview .Wt-tv-sh-down : column sort handle, sort down
.Wt-tableview .Wt-tv-br : header border
.Wt-tableview .Wt-spacer : spacer for non-loaded content .Wt-tableview .Wt-selected : selected item .Wt-tableview .Wt-drop-site : possible drop site .Wt-tableview .Wt-tv-c : cell style
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WAbstractItemView |
|---|
WAbstractItemView.EditOption, WAbstractItemView.EditTrigger, WAbstractItemView.ScrollHint |
| Constructor Summary | |
|---|---|
WTableView()
Constructor. |
|
WTableView(WContainerWidget parent)
Constructor. |
|
| Method Summary | |
|---|---|
int |
getCurrentPage()
Returns the current page. |
int |
getPageCount()
Returns the number of pages. |
int |
getPageSize()
Returns the page size. |
WWidget |
itemWidget(WModelIndex index)
Returns the widget that renders an item. |
void |
remove()
Destructor. |
void |
resize(WLength width,
WLength height)
Resizes the widget. |
void |
scrollTo(WModelIndex index,
WAbstractItemView.ScrollHint hint)
Scrolls the view to an item. |
void |
setAlternatingRowColors(boolean enable)
Sets if alternating row colors are to be used. |
void |
setColumnBorder(WColor color)
Sets the column border color. |
void |
setColumnHidden(int column,
boolean hidden)
Changes the visibility of a column. |
void |
setColumnWidth(int column,
WLength width)
Sets the column width. |
void |
setCurrentPage(int page)
Sets the current page. |
void |
setHeaderHeight(WLength height)
Sets the header height. |
void |
setHidden(boolean hidden,
WAnimation animation)
Hides or shows the widget. |
void |
setModel(WAbstractItemModel model)
Sets the model. |
void |
setRowHeaderCount(int count)
Configures the number of columns that are used as row headers. |
void |
setRowHeight(WLength rowHeight)
Sets the row height. |
| Methods inherited from class eu.webtoolkit.jwt.WWidget |
|---|
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, isRendered, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
addChild, getObjectName, setObjectName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WTableView(WContainerWidget parent)
public WTableView()
Calls this((WContainerWidget)null)
| Method Detail |
|---|
public void remove()
WWidgetDeletes a widget and all children (recursively). If the widget is contained in another widget, it is removed first.
remove in class WAbstractItemViewWContainerWidget.removeWidget(WWidget widget)public WWidget itemWidget(WModelIndex index)
WAbstractItemViewThis returns the widget that renders the given item. This may return 0 if the item is currently not rendered.
This widget has been created by an item delegate, and usually an item delegate is involved when updating it.
itemWidget in class WAbstractItemViewpublic void setModel(WAbstractItemModel model)
WAbstractItemView
The View will display data of the given model and changes in
the model are reflected by the View.
The initial model is null.
setModel in class WAbstractItemViewWAbstractItemView.setRootIndex(WModelIndex rootIndex)
public void setColumnWidth(int column,
WLength width)
WAbstractItemViewThe default column width is 150 pixels.
Note: The actual space occupied by each column is the column width augmented by 7 pixels for internal padding and a border.
setColumnWidth in class WAbstractItemViewpublic void setAlternatingRowColors(boolean enable)
WAbstractItemViewConfigure whether rows get alternating background colors, defined by the current CSS theme.
The default value is false.
setAlternatingRowColors in class WAbstractItemViewpublic void setRowHeight(WLength rowHeight)
WAbstractItemViewThe view renders all rows with a same height. This method configures this row height.
The default value is 20 pixels.
Note: The height must be specified in
WLength.Unit.Pixel units.
setRowHeight in class WAbstractItemViewWAbstractItemView.setColumnWidth(int column, WLength width)public void setHeaderHeight(WLength height)
WAbstractItemViewThe default value is 20 pixels.
setHeaderHeight in class WAbstractItemViewpublic void setColumnBorder(WColor color)
WAbstractItemViewThe default border color is defined by the CSS theme.
setColumnBorder in class WAbstractItemView
public void resize(WLength width,
WLength height)
WWidget
Specify a new size for this widget, by specifying width and height. By
default a widget has automatic width and height, see
WLength#isAuto().
This applies to CSS-based layout, and only
block widgets can be given a
size reliably.
When inserted in a layout manager, the widget may be informed about its
current size using setLayoutSizeAware(). If you have defined a
"wtResize()" JavaScript method for the widget,
then this method will also be called. operation.
resize in class WCompositeWidgetWWidget.getWidth(),
WWidget.getHeight()
public void setColumnHidden(int column,
boolean hidden)
WAbstractItemView
setColumnHidden in class WAbstractItemViewWAbstractItemView.isColumnHidden(int column)public void setRowHeaderCount(int count)
WAbstractItemViewAn item view does not use the vertical header data from the model in any way, but instead you can configure data in the first column(s) to be used as a row headers.
These columns will not scroll horizontally together with the rest of the model.
The default value is 0.
Note: Currently, this property must be set before any other settings of the view and only a value of 0 or 1 is supported.
setRowHeaderCount in class WAbstractItemViewpublic int getPageCount()
WAbstractItemViewWhen Ajax/JavaScript is not available, the view will use a paging navigation bar to allow scrolling through the data. This returns the number of pages currently shown.
getPageCount in class WAbstractItemViewWAbstractItemView.getCreatePageNavigationBar(),
WAbstractItemView.pageChanged()public int getPageSize()
WAbstractItemViewWhen Ajax/JavaScript is not available, the view will use a paging navigation bar to allow scrolling through the data. This returns the number of items per page.
getPageSize in class WAbstractItemViewWAbstractItemView.getCreatePageNavigationBar(),
WAbstractItemView.pageChanged()public int getCurrentPage()
WAbstractItemView
When Ajax/JavaScript is not available, the view will use a paging
navigation bar to allow scrolling through the data. This returns the
current page (between 0 and getPageCount() - 1).
getCurrentPage in class WAbstractItemViewWAbstractItemView.getCreatePageNavigationBar(),
WAbstractItemView.pageChanged()public void setCurrentPage(int page)
WAbstractItemViewWhen Ajax/JavaScript is not available, the view will use a paging navigation bar to allow scrolling through the data. This method can be used to change the current page.
setCurrentPage in class WAbstractItemViewWAbstractItemView.getCreatePageNavigationBar(),
WAbstractItemView.pageChanged()
public void scrollTo(WModelIndex index,
WAbstractItemView.ScrollHint hint)
WAbstractItemView
Scrolls the view to ensure that the item which represents the provided
index is visible. A hint may indicate how the
item should appear in the viewport (if possible).
Note: Currently only implemented to scroll to the correct row, not taking into account the column.
scrollTo in class WAbstractItemView
public void setHidden(boolean hidden,
WAnimation animation)
WWidget
Hides or show the widget (including all its descendant widgets). When
setting hidden = false, this widget and all
descendant widgets that are not hidden will be shown. A widget is only
visible if it and all its ancestors in the widget tree are visible, which
may be checked using isVisible().
setHidden in class WCompositeWidget
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||