Wt  3.7.1
Public Member Functions | Protected Member Functions | List of all members
Wt::WTableView Class Reference

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

#include <Wt/WTableView>

Inheritance diagram for Wt::WTableView:
Inheritance graph
[legend]

Public Member Functions

 WTableView (WContainerWidget *parent=0)
 Constructor.
 
virtual WWidgetitemWidget (const WModelIndex &index) const
 Returns the widget that renders an item. More...
 
virtual void setModel (WAbstractItemModel *model)
 Sets the model. More...
 
virtual void setColumnWidth (int column, const WLength &width)
 Sets the column width. More...
 
virtual void setAlternatingRowColors (bool enable)
 Sets if alternating row colors are to be used. More...
 
virtual void setRowHeight (const WLength &rowHeight)
 Sets the row height. More...
 
virtual void setHeaderHeight (const WLength &height)
 Sets the header height. More...
 
virtual void resize (const WLength &width, const WLength &height)
 Resizes the widget. More...
 
virtual void setColumnHidden (int column, bool hidden)
 Changes the visibility of a column. More...
 
virtual void setRowHeaderCount (int count)
 Configures the number of columns that are used as row headers. More...
 
virtual int pageCount () const
 Returns the number of pages. More...
 
virtual int pageSize () const
 Returns the page size. More...
 
virtual int currentPage () const
 Returns the current page. More...
 
virtual void setCurrentPage (int page)
 Sets the current page. More...
 
void scrollTo (int x, int y)
 Scrolls the view x px left and y px top.
 
void setOverflow (WContainerWidget::Overflow overflow, WFlags< Orientation > orientation=(Horizontal|Vertical))
 set css overflow
 
void setPreloadMargin (const WLength &margin, WFlags< Side > side=All)
 Sets preloading margin. More...
 
WLength preloadMargin (Side side) const
 Retrieves the preloading margin. More...
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())
 Hides or shows the widget. More...
 
WModelIndex modelIndexAt (WWidget *widget) const
 Returns the model index corresponding to a widget. More...
 
virtual EventSignal< WScrollEvent > & scrolled ()
 Signal emitted when scrolling. More...
 
- Public Member Functions inherited from Wt::WAbstractItemView
WAbstractItemModelmodel () const
 Returns the model. More...
 
void setRootIndex (const WModelIndex &rootIndex)
 Sets the root index. More...
 
const WModelIndexrootIndex () const
 Returns the root index. More...
 
void setItemDelegate (WAbstractItemDelegate *delegate)
 Sets the default item delegate. More...
 
WAbstractItemDelegateitemDelegate () const
 Returns the default item delegate. More...
 
void setItemDelegateForColumn (int column, WAbstractItemDelegate *delegate)
 Sets the delegate for a column. More...
 
WAbstractItemDelegateitemDelegateForColumn (int column) const
 Returns the delegate that was set for a column. More...
 
WAbstractItemDelegateitemDelegate (const WModelIndex &index) const
 Returns the delegate for rendering an item. More...
 
WAbstractItemDelegateitemDelegate (int column) const
 Returns the delegate for a column. More...
 
void setHeaderItemDelegate (WAbstractItemDelegate *delegate)
 Sets the header item delegate. More...
 
WAbstractItemDelegateheaderItemDelegate () const
 Returns the header item delegate. More...
 
virtual void setColumnAlignment (int column, AlignmentFlag alignment)
 Sets the content alignment for a column. More...
 
virtual AlignmentFlag columnAlignment (int column) const
 Returns the content alignment for a column. More...
 
virtual void setHeaderAlignment (int column, WFlags< AlignmentFlag > alignment)
 Sets the header alignment for a column. More...
 
AlignmentFlag headerAlignment (int column) const
 Returns the horizontal header alignment for a column (deprecated). More...
 
AlignmentFlag horizontalHeaderAlignment (int column) const
 Returns the horizontal header alignment for a column. More...
 
AlignmentFlag verticalHeaderAlignment (int column) const
 Returns the vertical header alignment for a column. More...
 
void setHeaderWordWrap (int column, bool enabled)
 Configures header text wrapping. More...
 
virtual bool alternatingRowColors () const
 Returns whether alternating row colors are used. More...
 
void sortByColumn (int column, SortOrder order)
 Sorts the data according to a column. More...
 
int sortColumn () const
 Returns the current sorting columm. More...
 
SortOrder sortOrder () const
 Returns the current sorting order. More...
 
void setSortingEnabled (bool enabled)
 Enables or disables sorting for all columns. More...
 
void setSortingEnabled (int column, bool enabled)
 Enables or disables sorting for a single column. More...
 
bool isSortingEnabled () const
 Returns whether sorting is enabled. More...
 
bool isSortingEnabled (int column) const
 Returns whether sorting is enabled for a single column. More...
 
void setColumnResizeEnabled (bool enabled)
 Enables interactive column resizing. More...
 
bool isColumnResizeEnabled () const
 Returns whether column resizing is enabled. More...
 
void setSelectionBehavior (SelectionBehavior behavior)
 Changes the selection behaviour. More...
 
SelectionBehavior selectionBehavior () const
 Returns the selection behaviour. More...
 
void setSelectionMode (SelectionMode mode)
 Sets the selection mode. More...
 
SelectionMode selectionMode () const
 Returns the selection mode. More...
 
WItemSelectionModelselectionModel () const
 Returns the selection model. More...
 
void setSelectedIndexes (const WModelIndexSet &indexes)
 Sets the selected items. More...
 
void clearSelection ()
 Clears the selection. More...
 
void select (const WModelIndex &index, SelectionFlag option=Select)
 Selects a single item. More...
 
bool isSelected (const WModelIndex &index) const
 Returns wheter an item is selected. More...
 
WModelIndexSet selectedIndexes () const
 Returns the set of selected items. More...
 
void setDragEnabled (bool enable)
 Enables the selection to be dragged (drag & drop). More...
 
void setDropsEnabled (bool enable)
 Enables drop operations (drag & drop). More...
 
const WLengthrowHeight () const
 Returns the row height.
 
WLength columnWidth (int column) const
 Returns the column width. More...
 
bool isColumnHidden (int column) const
 Returns if a column is hidden. More...
 
void hideColumn (int column)
 Hides a column. More...
 
void showColumn (int column)
 Shows a column. More...
 
virtual void setColumnBorder (const WColor &color)
 Sets the column border color (deprecated) More...
 
void setHeaderHeight (const WLength &height, bool multiLine)
 Sets the header height, and vertical alignment (deprecated). By default, the header text is a single line that is centered vertically. More...
 
const WLengthheaderHeight () const
 Returns the header height. More...
 
virtual void scrollTo (const WModelIndex &index, ScrollHint hint=EnsureVisible)=0
 Scrolls the view to an item. More...
 
void setEditTriggers (WFlags< EditTrigger > editTriggers)
 Configures what actions should trigger editing. More...
 
WFlags< EditTriggereditTriggers () const
 Returns the editing triggers. More...
 
void setEditOptions (WFlags< EditOption > options)
 Configures editing options. More...
 
WFlags< EditOptioneditOptions () const
 Returns the editing options. More...
 
void edit (const WModelIndex &index)
 Opens an editor for the given index. More...
 
void closeEditor (const WModelIndex &index, bool saveData=true)
 Closes the editor for the given index. More...
 
void closeEditors (bool saveData=true)
 Closes all open editors. More...
 
WValidator::State validateEditor (const WModelIndex &index)
 Validates the editor for the given index. More...
 
WValidator::State validateEditors ()
 Validates all editors. More...
 
bool isEditing (const WModelIndex &index) const
 Returns whether an editor is open for a given index. More...
 
bool isValid (const WModelIndex &index) const
 Returns whether an editor's state is valid.
 
Signal< WModelIndex, WMouseEvent > & clicked ()
 Signal emitted when clicked. More...
 
Signal< WModelIndex, WMouseEvent > & doubleClicked ()
 Signal emitted when double clicked. More...
 
Signal< WModelIndex, WMouseEvent > & mouseWentDown ()
 Signal emitted when a mouse button is pressed down. More...
 
Signal< WModelIndex, WMouseEvent > & mouseWentUp ()
 Signal emitted when the mouse button is released. More...
 
Signal< WModelIndex, WTouchEvent > & touchStart ()
 Signal emitted when a finger is placed on the screen. More...
 
Signal< std::vector< WModelIndex >, WTouchEvent > & touchStarted ()
 Signal emitted when one or more fingers are placed on the screen. More...
 
Signal< std::vector< WModelIndex >, WTouchEvent > & touchMoved ()
 Signal emitted when one or more fingers are moved on the screen. More...
 
Signal< std::vector< WModelIndex >, WTouchEvent > & touchEnded ()
 Signal emitted when one or more fingers are removed from the screen. More...
 
SignalselectionChanged ()
 Signal emitted when the selection is changed. More...
 
SignalpageChanged ()
 Signal emitted when page information was updated. More...
 
Signal< int, WLength > & columnResized ()
 Returns the signal emitted when a column is resized by the user. More...
 
bool sortEnabled ()
 Returns whether the view is sortable. More...
 
void setHeaderClickSortEnabled (bool enabled)
 Alow to sort. More...
 
Signal< int, WMouseEvent > & headerClicked ()
 Signal emitted when a header item is clicked. More...
 
Signal< int, WMouseEvent > & headerDoubleClicked ()
 Signal emitted when a header item is double clicked. More...
 
Signal< int, WMouseEvent > & headerMouseWentDown ()
 Signal emitted when a mouse button is pressed on a header item More...
 
Signal< int, WMouseEvent > & headerMouseWentUp ()
 Signal emitted when a mouse button is released on a header item More...
 
int rowHeaderCount () const
 Returns the number of columns that are used as row headers. More...
 
void setColumn1Fixed (bool enable)
 Configures whether horizontal scrolling includes the first column (deprecated) More...
 
bool column1Fixed () const
 Returns whether horizontal scrolling includes the first column. (deprecated) More...
 
virtual void setObjectName (const std::string &name)
 Sets an object name. More...
 
EventSignal< WKeyEvent > & keyWentDown ()
 Event signal emitted when a keyboard key is pushed down. More...
 
EventSignal< WKeyEvent > & keyPressed ()
 Event signal emitted when a "character" was entered. More...
 
EventSignal< WKeyEvent > & keyWentUp ()
 Event signal emitted when a keyboard key is released. More...
 
- Public Member Functions inherited from Wt::WCompositeWidget
 WCompositeWidget (WContainerWidget *parent=0)
 Creates a WCompositeWidget. More...
 
 WCompositeWidget (WWidget *implementation, WContainerWidget *parent)
 Creates a WCompositeWidget with given implementation. More...
 
virtual std::string objectName () const
 Returns the object name. More...
 
virtual const std::string id () const
 Returns the (unique) identifier for this object. More...
 
virtual void setPositionScheme (PositionScheme scheme)
 Sets the CSS position scheme. More...
 
virtual PositionScheme positionScheme () const
 Returns the CSS position scheme. More...
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=All)
 Sets CSS offsets for a non-statically positioned widget. More...
 
virtual WLength offset (Side s) const
 Returns a CSS offset. More...
 
virtual WLength width () const
 Returns the width. More...
 
virtual WLength height () const
 Returns the height. More...
 
virtual void setMinimumSize (const WLength &width, const WLength &height)
 Sets a minimum size. More...
 
virtual WLength minimumWidth () const
 Returns the minimum width. More...
 
virtual WLength minimumHeight () const
 Returns the minimum height. More...
 
virtual void setMaximumSize (const WLength &width, const WLength &height)
 Sets a maximum size. More...
 
virtual WLength maximumWidth () const
 Returns the maximum width. More...
 
virtual WLength maximumHeight () const
 Returns the maximum height. More...
 
virtual void setLineHeight (const WLength &height)
 Sets the CSS line height for contained text.
 
virtual WLength lineHeight () const
 Returns the CSS line height for contained text. More...
 
virtual void setFloatSide (Side s)
 Specifies a CSS float side. More...
 
virtual Side floatSide () const
 Returns the CSS float side. More...
 
virtual void setClearSides (WFlags< Side > sides)
 Sets the sides that should be cleared of floats. More...
 
virtual WFlags< SideclearSides () const
 Returns the sides that should remain empty. More...
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=All)
 Sets CSS margins around the widget. More...
 
virtual WLength margin (Side side) const
 Returns a CSS margin set. More...
 
virtual void setHiddenKeepsGeometry (bool enabled)
 Sets whether the widget keeps its geometry when hidden. More...
 
virtual bool hiddenKeepsGeometry () const
 Returns whether the widget keeps its geometry when hidden. More...
 
virtual bool isHidden () const
 Returns whether the widget is set hidden. More...
 
virtual bool isVisible () const
 Returns whether the widget is visible. More...
 
virtual void setDisabled (bool disabled)
 Sets whether the widget is disabled. More...
 
virtual bool isDisabled () const
 Returns whether the widget is set disabled. More...
 
virtual bool isEnabled () const
 Returns whether the widget is enabled. More...
 
virtual void setPopup (bool popup)
 Lets the widget overlay over other sibling widgets. More...
 
virtual bool isPopup () const
 Returns whether the widget is overlayed. More...
 
virtual void setInline (bool isInline)
 Sets whether the widget is displayed inline or as a block. More...
 
virtual bool isInline () const
 Returns whether the widget is displayed inline or as block. More...
 
virtual void setDecorationStyle (const WCssDecorationStyle &style)
 Sets a CSS decoration style. More...
 
virtual WCssDecorationStyledecorationStyle ()
 Returns the decoration style of this widget. More...
 
virtual void setStyleClass (const WString &styleClass)
 Sets (one or more) CSS style classes. More...
 
virtual WString styleClass () const
 Returns the CSS style class. More...
 
virtual void addStyleClass (const WString &styleClass, bool force=false)
 Adds a CSS style class. More...
 
virtual void removeStyleClass (const WString &styleClass, bool force=false)
 Removes a CSS style class. More...
 
virtual bool hasStyleClass (const WString &styleClass) const
 Returns whether the widget has a style class.
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto)
 Sets the vertical alignment. More...
 
virtual AlignmentFlag verticalAlignment () const
 Returns the vertical alignment. More...
 
virtual WLength verticalAlignmentLength () const
 Returns the fixed vertical alignment that was set. More...
 
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)
 Sets a tooltip. More...
 
virtual WString toolTip () const
 Returns the tooltip.
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=PlainText)
 Enable deferred tooltip. More...
 
virtual void refresh ()
 Refresh the widget. More...
 
virtual void setAttributeValue (const std::string &name, const WString &value)
 Sets an attribute value. More...
 
virtual WString attributeValue (const std::string &name) const
 Returns an attribute value. More...
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value)
 Sets a JavaScript member. More...
 
virtual std::string javaScriptMember (const std::string &name) const
 Returns the value of a JavaScript member. More...
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args)
 Calls a JavaScript member. More...
 
virtual void load ()
 Loads content just before the widget is used. More...
 
virtual bool loaded () const
 Returns whether this widget has been loaded. More...
 
virtual void setCanReceiveFocus (bool enabled)
 Sets whether the widget can receive focus. More...
 
virtual bool canReceiveFocus () const
 Returns whether the widget can receive focus. More...
 
virtual void setFocus (bool focus)
 Sets focus. More...
 
virtual bool setFirstFocus ()
 Set focus on the widget's first descendant. More...
 
virtual bool hasFocus () const
 Returns whether the widget currently has the focus.
 
virtual void setTabIndex (int index)
 Sets the tab index. More...
 
virtual int tabIndex () const
 Returns the tab index. More...
 
virtual void setId (const std::string &id)
 Sets the CSS Id. More...
 
virtual WWidgetfind (const std::string &name)
 Finds a descendent widget by name. More...
 
virtual WWidgetfindById (const std::string &name)
 Finds a descendent widget by id.
 
virtual void setSelectable (bool selectable)
 Sets as selectable. More...
 
virtual void doJavaScript (const std::string &js)
 Executes the given JavaScript statements when the widget is rendered or updated. More...
 
virtual void propagateSetEnabled (bool enabled)
 Propagates that a widget was enabled or disabled through children. More...
 
virtual bool scrollVisibilityEnabled () const WT_CXX11ONLY(final override)
 Returns whether scroll visibility detection is enabled for this widget. More...
 
virtual void setScrollVisibilityEnabled (bool enabled) WT_CXX11ONLY(final override)
 Sets whether scroll visibility detection is enabled for this widget. More...
 
virtual int scrollVisibilityMargin () const WT_CXX11ONLY(final override)
 Returns the margin around the viewport within which the widget is considered visible. More...
 
virtual void setScrollVisibilityMargin (int margin) WT_CXX11ONLY(final override)
 Sets the margin around the viewport within which the widget is considered visible. More...
 
virtual Signal< bool > & scrollVisibilityChanged () WT_CXX11ONLY(final override)
 Signal triggered when the scroll visibility of this widget changes. More...
 
virtual bool isScrollVisible () const WT_CXX11ONLY(final override)
 Returns whether this widget is currently considered scroll visible. More...
 
virtual void setThemeStyleEnabled (bool enabled)
 Sets whether theme styling for a widget is enabled or disabled. More...
 
virtual bool isThemeStyleEnabled () const
 Returns whether this widget is currently styled by the chosen theme. More...
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 Destructor. More...
 
WWidgetparent () const
 Returns the parent widget. More...
 
virtual void removeChild (WObject *child)
 Removes a child object. More...
 
void setWidth (const WLength &width)
 Sets the width. More...
 
void setHeight (const WLength &height)
 Sets the height. More...
 
virtual void positionAt (const WWidget *widget, Orientation orientation=Vertical)
 Positions a widget next to another widget. More...
 
virtual void toggleStyleClass (const WString &styleClass, bool add, bool force=false)
 Toggles a CSS style class.
 
std::string jsRef () const
 Returns a JavaScript expression to the corresponding DOM node. More...
 
void setFocus ()
 Sets focus. More...
 
virtual void acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString())
 Sets a mime type to be accepted for dropping. More...
 
virtual void stopAcceptDrops (const std::string &mimeType)
 Indicates that a mime type is no longer accepted for dropping. More...
 
virtual void htmlText (std::ostream &out)
 Streams the (X)HTML representation. More...
 
bool isRendered () const
 Returns whether the widget is rendered. More...
 
void hide ()
 Hides the widget. More...
 
void animateHide (const WAnimation &animation)
 Hides the widget using an animation. More...
 
void show ()
 Shows the widget. More...
 
void animateShow (const WAnimation &animation)
 Shows the widget using an animation. More...
 
void enable ()
 Enables the widget. More...
 
void disable ()
 Disable thes widget. More...
 
bool layoutSizeAware () const
 Returns whether the widget is layout size aware. More...
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 Create a WObject with a given parent object. More...
 
virtual ~WObject ()
 Destructor. More...
 
void resetLearnedSlots ()
 Resets learned stateless slot implementations. More...
 
template<class T >
void resetLearnedSlot (void(T::*method)())
 Resets a learned stateless slot implementation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)())
 Declares a slot to be stateless and learn client-side behaviour on first invocation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 Declares a slot to be stateless and learn client-side behaviour in advance. More...
 
void isNotStateless ()
 Marks the current function as not stateless. More...
 
template<class T >
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 Provides a JavaScript implementation for a method. More...
 
void addChild (WObject *child)
 Adds a child object. More...
 
const std::vector< WObject * > & children () const
 Returns the children.
 
WObjectparent () const
 Returns the parent object.
 

Protected Member Functions

virtual void render (WFlags< RenderFlag > flags)
 Renders the widget. More...
 
virtual void adjustSize ()
 Called when rows or columns are inserted/removed. More...
 
virtual void enableAjax ()
 Progresses to an Ajax-enabled widget. More...
 
- Protected Member Functions inherited from Wt::WAbstractItemView
 WAbstractItemView (WContainerWidget *parent=0)
 Creates a new item view.
 
virtual void dropEvent (const WDropEvent &event, const WModelIndex &target)
 Handles a drop event (drag & drop). More...
 
virtual WWidgetcreateExtraHeaderWidget (int column)
 Create an extra widget in the header. More...
 
WWidgetextraHeaderWidget (int column)
 Returns the extra header widget. More...
 
virtual WWidgetcreatePageNavigationBar ()
 Returns a page navigation widget. More...
 
virtual void handleClick (const WModelIndex &index, const WMouseEvent &event)
 Handles a click event. More...
 
virtual void handleDoubleClick (const WModelIndex &index, const WMouseEvent &event)
 Handles a double click event. More...
 
virtual void handleMouseDown (const WModelIndex &index, const WMouseEvent &event)
 Handles a mouse down event. More...
 
virtual void handleMouseUp (const WModelIndex &index, const WMouseEvent &event)
 Handles a mouse up event. More...
 
virtual void handleTouchSelect (const std::vector< WModelIndex > &indices, const WTouchEvent &event)
 Handles a touch select event.
 
virtual void handleTouchStart (const std::vector< WModelIndex > &indices, const WTouchEvent &event)
 Handles a touch started event.
 
virtual void handleTouchMove (const std::vector< WModelIndex > &indices, const WTouchEvent &event)
 Handles a touch moved event.
 
virtual void handleTouchEnd (const std::vector< WModelIndex > &indices, const WTouchEvent &event)
 Handles a touch ended event.
 
- Protected Member Functions inherited from Wt::WCompositeWidget
void setImplementation (WWidget *widget)
 Set the implementation widget. More...
 
WWidgetimplementation ()
 Get the implementation widget. More...
 
virtual int boxPadding (Orientation orientation) const
 Returns the widget's built-in padding. More...
 
virtual int boxBorder (Orientation orientation) const
 Returns the widget's built-in border width. More...
 
- Protected Member Functions inherited from Wt::WWidget
void setLayoutSizeAware (bool sizeAware)
 Sets the widget to be aware of its size set by a layout manager. More...
 
virtual void layoutSizeChanged (int width, int height)
 Virtual method that indicates a size change. More...
 
 WWidget (WContainerWidget *parent=0)
 Creates a widget. More...
 
virtual void dropEvent (WDropEvent dropEvent)
 Handles a drop event. More...
 
void scheduleRender (WFlags< RepaintFlag > flags=0)
 Schedules rerendering of the widget. More...
 
virtual WStatelessSlot * getStateless (Method method)
 On-demand stateless slot implementation. More...
 

Additional Inherited Members

- Public Types inherited from Wt::WAbstractItemView
enum  EditTrigger { NoEditTrigger = 0x0, SingleClicked = 0x1, DoubleClicked = 0x2, SelectedClicked = 0x4 }
 Enumeration that specifies the user action that triggers editing. More...
 
enum  EditOption { SingleEditor = 0x1, MultipleEditors = 0x2, SaveWhenClosed = 0x4, LeaveEditorsOpen = 0x8 }
 Enumeration that specifies editing options. More...
 
enum  ScrollHint { EnsureVisible, PositionAtTop, PositionAtBottom, PositionAtCenter }
 Enumeration that specifies a scrolling option. More...
 
- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 Typedef for a WObject method without arguments.
 
- Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 Short hand for WString::tr() More...
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 Returns the sender of the current slot call. More...
 

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

When the view is updated, it will read the data from the model row per row, starting at the top visible row. If (r1,c1) and (r2,c2) are two model indexes of visible table cells, and r1 < r2 or r1 == r2 and c1 < c2, then the data for the first model index is read before the second. Keep this into account when implementing a custom WAbstractItemModel if you want to optimize performance.

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.

If a WTableView is not constrained in height (either by a layout manager or by setHeight()), then it will grow according to the size of the model.

Member Function Documentation

◆ adjustSize()

virtual void Wt::WTableView::adjustSize ( )
protectedvirtual

Called when rows or columns are inserted/removed.

Override this method when you want to adjust the table's size when columns or rows are inserted or removed. The method is also called when the model is reset. The default implementation does nothing.

◆ currentPage()

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.

◆ enableAjax()

void Wt::WTableView::enableAjax ( )
protectedvirtual

Progresses to an Ajax-enabled widget.

This method is called when the progressive bootstrap method is used, and support for AJAX has been detected. The default behavior will upgrade the widget's event handling to use AJAX instead of full page reloads, and propagate the call to its children.

You may want to reimplement this method if you want to make changes to widget when AJAX is enabled. You should always call the base implementation.

See also
WApplication::enableAjax()

Reimplemented from Wt::WCompositeWidget.

◆ itemWidget()

WWidget * Wt::WTableView::itemWidget ( const WModelIndex index) const
virtual

Returns the widget that renders an item.

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

Implements Wt::WAbstractItemView.

◆ modelIndexAt()

WModelIndex Wt::WTableView::modelIndexAt ( WWidget widget) const

Returns the model index corresponding to a widget.

This returns the model index for the item that is or contains the given widget.

◆ pageCount()

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.

◆ pageSize()

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.

◆ preloadMargin()

WLength Wt::WTableView::preloadMargin ( Side  side) const

Retrieves the preloading margin.

See also
setPreloadMargin

◆ render()

void Wt::WTableView::render ( WFlags< RenderFlag flags)
protectedvirtual

Renders the widget.

This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().

The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.

Reimplemented from Wt::WCompositeWidget.

◆ resize()

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

Resizes the widget.

Specifies a fixed size for this widget, setting CSS width and height properties. By default a widget has automatic width and height, which sets a size for the widget following CSS rules.

When the widget is not managed by a layout manager, the automatic (natural) size of a widget depends on whether they widget is a block or inline widget:

  • a block widget takes by default the width of the parent, and the height that it needs based on its contents
  • an inline widget takes the width and height that it needs based on its contents (possibly wrapping over multiple lines). The width and height of an inline widget cannot be changed (by the letter of CSS, although most browsers will react to it in varying ways).

When inserted in a layout manager, the size set will be used as a widget's preferred size, but the widget may be given a different size by the layout manager based on available space and stretch factors. The actual size given by a layout manager may be retrieved by making the widget "layout size aware", using setLayoutSizeAware(). If you have defined a "wtResize()" JavaScript method for the widget, then this method will also be called.

The default width and height of a widget is WLength::Auto.

See also
width(), height()

Reimplemented from Wt::WCompositeWidget.

◆ scrolled()

EventSignal< WScrollEvent > & Wt::WTableView::scrolled ( )
virtual

Signal emitted when scrolling.

Note
Works only if ajax is available.

Implements Wt::WAbstractItemView.

◆ setAlternatingRowColors()

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.

◆ setColumnHidden()

void Wt::WTableView::setColumnHidden ( int  column,
bool  hide 
)
virtual

Changes the visibility of a column.

See also
isColumnHidden()

Reimplemented from Wt::WAbstractItemView.

◆ setColumnWidth()

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

Sets the column width.

The default column width is 150 pixels.

Note
The width must be specified in WLength::Pixel units.
The actual space occupied by each column is the column width augmented by 7 pixels for internal padding and a border.

Implements Wt::WAbstractItemView.

◆ setCurrentPage()

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.

◆ setHeaderHeight()

void Wt::WTableView::setHeaderHeight ( const WLength height)
virtual

Sets the header height.

The default value is 20 pixels.

Note
The height must be specified in WLength::Pixel units.

Reimplemented from Wt::WAbstractItemView.

◆ setHidden()

void Wt::WTableView::setHidden ( bool  hidden,
const WAnimation animation = WAnimation() 
)
virtual

Hides or shows the widget.

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

Note
hide() and show() are considered to be stateless slots by default. If you override setHidden() and need to modify server state whenever it is called, you'll need to call WObject::isNotStateless().

Reimplemented from Wt::WCompositeWidget.

◆ setModel()

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.

◆ setPreloadMargin()

void Wt::WTableView::setPreloadMargin ( const WLength margin,
WFlags< Side side = All 
)

Sets preloading margin.

By default the table view loads in an area equal to 3 times its height and 3 times its width. This makes it so that the user can scroll a full page in each direction without the delay caused when the table view dynamically needs to load more data.

setPreloadMargin() allows to customize this margin.

e.g. if the table view is H pixels high, and C is the preload margin in pixels set on the top and bottom, then enough rows are loaded to fill the area that is H + 2C pixels high. H pixels visible, C pixels above, and C pixels below.

Set to 0 pixels if you don't want to load more rows or columns than are currently visible.

Set to a default-constructed WLength (auto) if you want to keep default behaviour.

◆ setRowHeaderCount()

void Wt::WTableView::setRowHeaderCount ( int  count)
virtual

Configures the number of columns that are used as row headers.

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

Reimplemented from Wt::WAbstractItemView.

◆ setRowHeight()

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.


Generated on Tue Dec 15 2020 for the C++ Web Toolkit (Wt) by doxygen 1.8.13