Wt::WTableView Class Reference
[Model/view system]

An MVC View widget for tabular data. More...

#include <Wt/WTableView>

Inheritance diagram for Wt::WTableView:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 WTableView (WContainerWidget *parent=0)
 Constructor.
virtual void setModel (WAbstractItemModel *model)
 Sets the model.
virtual void setColumnWidth (int column, const WLength &width)
 Sets the column width.
virtual void setAlternatingRowColors (bool enable)
 Sets if alternating row colors are to be used.
virtual void setRowHeight (const WLength &rowHeight)
 Sets the row height.
virtual void setHeaderHeight (const WLength &height, bool multiLine=false)
 Sets the header height.
virtual void setColumnBorder (const WColor &color)
 Sets the column border color.
virtual void resize (const WLength &width, const WLength &height)
 Resizes the widget.
virtual int pageCount () const
 Returns the number of pages.
virtual int pageSize () const
 Returns the page size.
virtual int currentPage () const
 Returns the current page.
virtual void setCurrentPage (int page)
 Sets the current page.


Detailed Description

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 Wt::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 Wt::ItemIsEditable flag). You can define triggers that initiate editing of an item using setEditTriggers(). The actual editing is provided by the item delegate (you can set an appropriate delegate for one column using setItemDelegateForColumn()). Using 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 setSortingEnabled().

You can allow selection on row or item level (using setSelectionBehavior()), and selection of single or multiple items (using setSelectionMode()), and listen for changes in the selection using the selectionChanged() signal.

You may enable drag & drop support for this view, whith awareness of the items in the model. When enabling dragging (see 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::mimeType()). Likewise, by enabling support for dropping (see 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 clicked() or doubleClicked() signals.


Member Function Documentation

void Wt::WTableView::setModel ( WAbstractItemModel model  )  [virtual]

Sets the model.

The View will display data of the given model and changes in the model are reflected by the View.

The initial model is 0.

Ownership of the model is not transferred (and thus the previously set model is not deleted). A model may not be deleted as long as a view exists for it.

See also:
setRootIndex()

Reimplemented from Wt::WAbstractItemView.

void Wt::WTableView::setColumnWidth ( int  column,
const WLength width 
) [virtual]

Sets the column width.

The 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.

Implements Wt::WAbstractItemView.

void Wt::WTableView::setAlternatingRowColors ( bool  enable  )  [virtual]

Sets if alternating row colors are to be used.

Configure whether rows get alternating background colors, defined by the current CSS theme.

The default value is false.

Reimplemented from Wt::WAbstractItemView.

void Wt::WTableView::setRowHeight ( const WLength rowHeight  )  [virtual]

Sets the row height.

The 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::Pixel units.
See also:
setColumnWidth()

Reimplemented from Wt::WAbstractItemView.

void Wt::WTableView::setHeaderHeight ( const WLength height,
bool  multiLine = false 
) [virtual]

Sets the header height.

Use this method to change the header height. By default, the header text is a single line that is centered vertically.

By enabling multi-line headers, the header text will be aligned to the top and wrap as needed. In that case, additional contents may be displayed in the header, provided by createExtraHeaderWidget().

The default value is a single line of 20 pixels.

Reimplemented from Wt::WAbstractItemView.

void Wt::WTableView::setColumnBorder ( const WColor color  )  [virtual]

Sets the column border color.

The default border color is defined by the CSS theme.

Implements Wt::WAbstractItemView.

void Wt::WTableView::resize ( const WLength width,
const WLength height 
) [virtual]

Resizes the widget.

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.

See also:
width(), height()

Reimplemented from Wt::WCompositeWidget.

int Wt::WTableView::pageCount (  )  const [virtual]

Returns the number of pages.

When 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.

See also:
createPageNavigationBar(), pageChanged()

Implements Wt::WAbstractItemView.

int Wt::WTableView::pageSize (  )  const [virtual]

Returns the page size.

When 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.

See also:
createPageNavigationBar(), pageChanged()

Implements Wt::WAbstractItemView.

int Wt::WTableView::currentPage (  )  const [virtual]

Returns the current page.

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 pageCount() - 1).

See also:
createPageNavigationBar(), pageChanged()

Implements Wt::WAbstractItemView.

void Wt::WTableView::setCurrentPage ( int  page  )  [virtual]

Sets the current page.

When 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.

See also:
createPageNavigationBar(), pageChanged()

Implements Wt::WAbstractItemView.


Generated on Thu May 20 18:14:49 2010 for Wt by doxygen 1.5.6