DataTable renders data in either a scrollable grid (the default) or a list view optimised for portrait iPhone. It accepts a TableModel as its single data source.
Data model overview
The data model is composed of two main types:| Type | Role |
|---|---|
TableModel | Observable data source: header row, data rows, layout options |
TableRowItem | A single row: an array of DataItem cells plus optional leading/trailing accessories |
DataItem types
| Type | Use for |
|---|---|
DataTextItem | Plain or styled string values |
DataImageItem | An Image value |
DataDateItem | A Date formatted by the column’s ColumnAttribute |
DataTimeItem | A time-only Date |
DataDurationItem | A TimeInterval formatted as a duration |
DataListItem | A string selected from a predefined list (supports inline editing) |
Creating a DataTable
Key TableModel parameters
The header row. When
nil, no header is rendered.The array of data rows.
Keeps the header visible when the user scrolls vertically.
Keeps the first column visible when the user scrolls horizontally.
Switches to list layout (suited to iPhone portrait). In list mode each row maps to an
ObjectItem using automatic field binding..none — display only. .select — row selection checkboxes. .inline — individual cell editing.Enables two-finger zoom on the grid.
Per-column width, alignment, and formatting attributes.
DataTable view modifiers
Inline editing
To enable inline editing, seteditMode to .inline and supply a validateDataItem closure:
model.onSave(true) to commit changes or model.onSave(false) to roll them back.
List view mode and automatic ObjectItem binding
WhenshowListView is true, DataTable maps each TableRowItem to an ObjectItem using positional field binding:
| Column index | ObjectItem field |
|---|---|
| 0 (text) | title |
| 1 (text) | subtitle |
| 2 (text) | footnote |
| 3 (text) | status |
| 4 (text) | substatus |
| 0 (image) | detailImage |
Set
DataTable.showListView(true) via the view modifier or the TableModel property. In list view mode, horizontal scrolling is disabled and the rows render as standard Fiori list items.