Wt  4.11.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.h>

Inheritance diagram for Wt::WTableView:
[legend]

Public Member Functions

 WTableView ()
 Constructor.
 
virtual WWidgetitemWidget (const WModelIndex &index) const override
 Returns the widget that renders an item. More...
 
virtual void setModel (const std::shared_ptr< WAbstractItemModel > &model) override
 Sets the model. More...
 
virtual void setColumnWidth (int column, const WLength &width) override
 Sets the column width. More...
 
virtual void setAlternatingRowColors (bool enable) override
 Sets if alternating row colors are to be used. More...
 
virtual void setRowHeight (const WLength &rowHeight) override
 Sets the row height. More...
 
virtual void setHeaderHeight (const WLength &height) override
 Sets the header height. More...
 
virtual void resize (const WLength &width, const WLength &height) override
 Resizes the widget. More...
 
virtual void setColumnHidden (int column, bool hidden) override
 Changes the visibility of a column. More...
 
virtual void setRowHeaderCount (int count) override
 Configures the number of columns that are used as row headers. More...
 
virtual int pageCount () const override
 Returns the number of pages. More...
 
virtual int pageSize () const override
 Returns the page size. More...
 
virtual int currentPage () const override
 Returns the current page. More...
 
virtual void setCurrentPage (int page) override
 Sets the current page. More...
 
virtual void scrollTo (const WModelIndex &index, ScrollHint hint=ScrollHint::EnsureVisible) override
 Scrolls the view to an item. More...
 
void scrollTo (int x, int y)
 Scrolls the view x px left and y px top.
 
void setOverflow (Overflow overflow, WFlags< Orientation > orientation=(Orientation::Horizontal|Orientation::Vertical))
 set css overflow
 
void setPreloadMargin (const WLength &margin, WFlags< Side > side=AllSides)
 Sets preloading margin. More...
 
WLength preloadMargin (Side side) const
 Retrieves the preloading margin. More...
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation()) override
 Hides or shows the widget. More...
 
WModelIndex modelIndexAt (WWidget *widget) const
 Returns the model index corresponding to a widget. More...
 
virtual EventSignal< WScrollEvent > & scrolled () override
 Signal emitted when scrolling. More...
 
virtual void setHeaderHeight (const WLength &height)
 Sets the header height. More...
 
- Public Member Functions inherited from Wt::WAbstractItemView
std::shared_ptr< 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 (const std::shared_ptr< WAbstractItemDelegate > &delegate)
 Sets the default item delegate. More...
 
std::shared_ptr< WAbstractItemDelegateitemDelegate () const
 Returns the default item delegate. More...
 
void setItemDelegateForColumn (int column, const std::shared_ptr< WAbstractItemDelegate > &delegate)
 Sets the delegate for a column. More...
 
std::shared_ptr< WAbstractItemDelegateitemDelegateForColumn (int column) const
 Returns the delegate that was set for a column. More...
 
std::shared_ptr< WAbstractItemDelegateitemDelegate (const WModelIndex &index) const
 Returns the delegate for rendering an item. More...
 
std::shared_ptr< WAbstractItemDelegateitemDelegate (int column) const
 Returns the delegate for a column. More...
 
void setHeaderItemDelegate (const std::shared_ptr< WAbstractItemDelegate > &delegate)
 Sets the header item delegate. More...
 
std::shared_ptr< 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 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...
 
void setColumnResizeEnabled (bool enabled, int column)
 Enables interactive column resizing. More...
 
bool isColumnResizeEnabled () const
 Returns whether column resizing is enabled for new columns. More...
 
bool isColumnResizeEnabled (int column) const
 Returns whether column resizing is enabled for a single column. 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=SelectionFlag::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...
 
void setEnabledDropLocations (WFlags< DropLocation > droplocation)
 Enables drop operations (drag & drop). More...
 
WFlags< DropLocationenabledDropLocations () const
 Returns the enabled drop locations.
 
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...
 
const WLengthheaderHeight () const
 Returns the header height. 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...
 
ValidationState validateEditor (const WModelIndex &index)
 Validates the editor for the given index. More...
 
ValidationState 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...
 
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 ()
 Creates a WCompositeWidget. More...
 
 WCompositeWidget (std::unique_ptr< WWidget > implementation)
 Creates a WCompositeWidget with given implementation. More...
 
virtual std::vector< WWidget * > children () const override
 Returns child widgets. More...
 
virtual std::unique_ptr< WWidgetremoveWidget (WWidget *widget) override
 Removes a child widget.
 
virtual void setObjectName (const std::string &name) override
 Sets an object name. More...
 
virtual std::string objectName () const override
 Returns the object name. More...
 
virtual const std::string id () const override
 Returns the (unique) identifier for this object. More...
 
virtual void setPositionScheme (PositionScheme scheme) override
 Sets the CSS position scheme. More...
 
virtual PositionScheme positionScheme () const override
 Returns the CSS position scheme. More...
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=AllSides) override
 Sets CSS offsets for a non-statically positioned widget. More...
 
virtual WLength offset (Side s) const override
 Returns a CSS offset. More...
 
virtual WLength width () const override
 Returns the width. More...
 
virtual WLength height () const override
 Returns the height. More...
 
virtual void setMinimumSize (const WLength &width, const WLength &height) override
 Sets a minimum size. More...
 
virtual WLength minimumWidth () const override
 Returns the minimum width. More...
 
virtual WLength minimumHeight () const override
 Returns the minimum height. More...
 
virtual void setMaximumSize (const WLength &width, const WLength &height) override
 Sets a maximum size. More...
 
virtual WLength maximumWidth () const override
 Returns the maximum width. More...
 
virtual WLength maximumHeight () const override
 Returns the maximum height. More...
 
virtual void setLineHeight (const WLength &height) override
 Sets the CSS line height for contained text.
 
virtual WLength lineHeight () const override
 Returns the CSS line height for contained text. More...
 
virtual void setFloatSide (Side s) override
 Specifies a CSS float side. More...
 
virtual Side floatSide () const override
 Returns the CSS float side. More...
 
virtual void setClearSides (WFlags< Side > sides) override
 Sets the sides that should be cleared of floats. More...
 
virtual WFlags< SideclearSides () const override
 Returns the sides that should remain empty. More...
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=AllSides) override
 Sets CSS margins around the widget. More...
 
virtual WLength margin (Side side) const override
 Returns a CSS margin set. More...
 
virtual void setHiddenKeepsGeometry (bool enabled) override
 Sets whether the widget keeps its geometry when hidden. More...
 
virtual bool hiddenKeepsGeometry () const override
 Returns whether the widget keeps its geometry when hidden. More...
 
virtual bool isHidden () const override
 Returns whether the widget is set hidden. More...
 
virtual bool isVisible () const override
 Returns whether the widget is visible. More...
 
virtual void setDisabled (bool disabled) override
 Sets whether the widget is disabled. More...
 
virtual bool isDisabled () const override
 Returns whether the widget is set disabled. More...
 
virtual bool isEnabled () const override
 Returns whether the widget is enabled. More...
 
virtual void setPopup (bool popup) override
 Lets the widget overlay over other sibling widgets. More...
 
virtual bool isPopup () const override
 Returns whether the widget is overlayed. More...
 
virtual void setInline (bool isInline) override
 Sets whether the widget is displayed inline or as a block. More...
 
virtual bool isInline () const override
 Returns whether the widget is displayed inline or as block. More...
 
virtual void setDecorationStyle (const WCssDecorationStyle &style) override
 Sets a CSS decoration style. More...
 
virtual WCssDecorationStyledecorationStyle () override
 Returns the decoration style of this widget. More...
 
virtual void setStyleClass (const WString &styleClass) override
 Sets (one or more) CSS style classes. More...
 
virtual WString styleClass () const override
 Returns the CSS style class. More...
 
virtual void addStyleClass (const WString &styleClass, bool force=false) override
 Adds a CSS style class. More...
 
virtual void removeStyleClass (const WString &styleClass, bool force=false) override
 Removes a CSS style class. More...
 
virtual bool hasStyleClass (const WString &styleClass) const override
 Returns whether the widget has a style class.
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto) override
 Sets the vertical alignment. More...
 
virtual AlignmentFlag verticalAlignment () const override
 Returns the vertical alignment. More...
 
virtual WLength verticalAlignmentLength () const override
 Returns the fixed vertical alignment that was set. More...
 
virtual void setToolTip (const WString &text, TextFormat textFormat=TextFormat::Plain) override
 Sets a tooltip. More...
 
virtual WString toolTip () const override
 Returns the tooltip.
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=TextFormat::Plain) override
 Enable deferred tooltip. More...
 
virtual void refresh () override
 Refresh the widget. More...
 
virtual void setAttributeValue (const std::string &name, const WString &value) override
 Sets an attribute value. More...
 
virtual WString attributeValue (const std::string &name) const override
 Returns an attribute value. More...
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value) override
 Sets a JavaScript member. More...
 
virtual std::string javaScriptMember (const std::string &name) const override
 Returns the value of a JavaScript member. More...
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args) override
 Calls a JavaScript member. More...
 
virtual void load () override
 Loads content just before the widget is used. More...
 
virtual bool loaded () const override
 Returns whether this widget has been loaded. More...
 
virtual void setCanReceiveFocus (bool enabled) override
 Sets whether the widget can receive focus. More...
 
virtual bool canReceiveFocus () const override
 Returns whether the widget can receive focus. More...
 
virtual void setFocus (bool focus) override
 Sets focus. More...
 
virtual bool setFirstFocus () override
 Set focus on the widget's first descendant. More...
 
virtual bool hasFocus () const override
 Returns whether the widget currently has the focus.
 
virtual void setTabIndex (int index) override
 Sets the tab index. More...
 
virtual int tabIndex () const override
 Returns the tab index. More...
 
virtual void setId (const std::string &id) override
 Sets the CSS Id. More...
 
virtual WWidgetfind (const std::string &name) override
 Finds a descendent widget by name. More...
 
virtual WWidgetfindById (const std::string &name) override
 Finds a descendent widget by id.
 
virtual void setSelectable (bool selectable) override
 Sets as selectable. More...
 
virtual void doJavaScript (const std::string &js) override
 Executes the given JavaScript statements when the widget is rendered or updated. More...
 
virtual void propagateSetEnabled (bool enabled) override
 Propagates that a widget was enabled or disabled through children. More...
 
virtual bool scrollVisibilityEnabled () const final override
 Returns whether scroll visibility detection is enabled for this widget. More...
 
virtual void setScrollVisibilityEnabled (bool enabled) final override
 Sets whether scroll visibility detection is enabled for this widget. More...
 
virtual int scrollVisibilityMargin () const final override
 Returns the margin around the viewport within which the widget is considered visible. More...
 
virtual void setScrollVisibilityMargin (int margin) final override
 Sets the margin around the viewport within which the widget is considered visible. More...
 
virtual Signal< bool > & scrollVisibilityChanged () final override
 Signal triggered when the scroll visibility of this widget changes. More...
 
virtual bool isScrollVisible () const final override
 Returns whether this widget is currently considered scroll visible. More...
 
virtual void setThemeStyleEnabled (bool enabled) final override
 Sets whether theme styling for a widget is enabled or disabled. More...
 
virtual bool isThemeStyleEnabled () const final override
 Returns whether this widget is currently styled by the chosen theme. More...
 
virtual std::unique_ptr< WWidgetremoveWidget (WWidget *widget)
 Removes a child widget.
 
template<typename Widget >
std::unique_ptr< Widget > removeWidget (Widget *widget)
 Removes a child widget. More...
 
void setFocus ()
 Sets focus. More...
 
virtual void setFocus (bool focus)=0
 Sets focus. More...
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 Destructor. More...
 
WWidgetparent () const
 Returns the parent widget.
 
template<typename Widget >
std::unique_ptr< Widget > removeWidget (Widget *widget)
 Removes a child widget. More...
 
std::unique_ptr< WWidgetremoveFromParent ()
 Removes the widget from its parent. 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=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
void addChild (std::unique_ptr< WObject > child)
 Add a child WObject whose lifetime is determined by this WObject.
 
template<typename Child >
Child * addChild (std::unique_ptr< Child > child)
 Add a child WObject, returning a raw pointer. More...
 
std::unique_ptr< WObjectremoveChild (WObject *child)
 Remove a child WObject, so its lifetime is no longer determined by this WObject.
 
template<typename Child >
std::unique_ptr< Child > removeChild (Child *child)
 Remove a child WObject, so its lifetime is no longer determined by this WObject. 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...
 
- Public Member Functions inherited from Wt::Core::observable
 observable () noexcept
 Default constructor.
 
virtual ~observable ()
 Destructor. More...
 
template<typename... Args, typename C >
auto bindSafe (void(C::*method)(Args...)) noexcept
 Protects a method call against object destruction. More...
 
template<typename... Args, typename C >
auto bindSafe (void(C::*method)(Args...) const) const noexcept
 Protects a const method call against object destruction. More...
 
template<typename Function >
auto bindSafe (const Function &function) noexcept
 Protects a function against object destruction. More...
 

Protected Member Functions

virtual void render (WFlags< RenderFlag > flags) override
 Renders the widget. More...
 
virtual void adjustSize ()
 Called when rows or columns are inserted/removed. More...
 
virtual void enableAjax () override
 Progresses to an Ajax-enabled widget. More...
 
- Protected Member Functions inherited from Wt::WAbstractItemView
 WAbstractItemView ()
 Creates a new item view.
 
virtual void dropEvent (const WDropEvent &event, const WModelIndex &target)
 Handles a drop event (drag & drop). More...
 
virtual void dropEvent (const WDropEvent &event, const WModelIndex &index, Wt::Side side)
 Handles a drop event (drag & drop). More...
 
virtual std::unique_ptr< WWidgetcreateExtraHeaderWidget (int column)
 Create an extra widget in the header. More...
 
WWidgetextraHeaderWidget (int column)
 Returns the extra header widget. More...
 
virtual std::unique_ptr< 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.
 
virtual void dropEvent (WDropEvent dropEvent)
 Handles a drop event. More...
 
- Protected Member Functions inherited from Wt::WCompositeWidget
void setImplementation (std::unique_ptr< WWidget > widget)
 Set the implementation widget. More...
 
template<typename Widget >
Widget * setImplementation (std::unique_ptr< Widget > widget)
 Sets the implementation widget, returning a raw pointer. More...
 
template<typename W , typename... Args>
W * setNewImplementation (Args &&... args)
 Creates the implementation widget and sets it, returning a raw pointer. More...
 
WWidgetimplementation ()
 Get the implementation widget. More...
 
virtual int boxPadding (Orientation orientation) const override
 Returns the widget's built-in padding. More...
 
virtual int boxBorder (Orientation orientation) const override
 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 ()
 Creates a widget.
 
virtual void dropEvent (WDropEvent dropEvent)
 Handles a drop event. More...
 
void scheduleRender (WFlags< RepaintFlag > flags=None)
 Schedules rerendering of the widget. More...
 
virtual WStatelessSlot * getStateless (Method method) override
 On-demand stateless slot implementation. More...
 

Additional Inherited Members

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

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::ItemFlag::Editable 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, with 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 ItemFlag::DragEnabled 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 ItemFlag::DropEnabled 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
overridevirtual

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

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::WAbstractItemView.

◆ itemWidget()

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

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
overridevirtual

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
overridevirtual

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

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

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

Signal emitted when scrolling.

Note
Works only if ajax is available.

Implements Wt::WAbstractItemView.

◆ scrollTo()

void Wt::WTableView::scrollTo ( const WModelIndex index,
ScrollHint  hint = ScrollHint::EnsureVisible 
)
overridevirtual

Scrolls the view to an item.

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.

Implements Wt::WAbstractItemView.

◆ setAlternatingRowColors()

void Wt::WTableView::setAlternatingRowColors ( bool  enable)
overridevirtual

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

Changes the visibility of a column.

See also
isColumnHidden()

Reimplemented from Wt::WAbstractItemView.

◆ setColumnWidth()

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

Sets the column width.

The default column width is 150 pixels.

Note
The width must be specified in LengthUnit::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)
overridevirtual

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() [1/2]

void Wt::WAbstractItemView::setHeaderHeight

Sets the header height.

The default value is 20 pixels.

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

◆ setHeaderHeight() [2/2]

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

Sets the header height.

The default value is 20 pixels.

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

Reimplemented from Wt::WAbstractItemView.

◆ setHidden()

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

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 ( const std::shared_ptr< WAbstractItemModel > &  model)
overridevirtual

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.

See also
setRootIndex()

Reimplemented from Wt::WAbstractItemView.

◆ setPreloadMargin()

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

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

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

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

Reimplemented from Wt::WAbstractItemView.