Skip to main content
Light Dark System

Datagrid

<et2-datagrid> | Et2Datagrid
Since 23.1

Virtualized data grid for infinite rows with column sizing, selection, and lazy paging.

Et2Datagrid

et2-datagrid renders a virtualized table/grid from:

  • columns metadata
  • row template data (templateData)
  • row data from a dataProvider or preloaded rows

This page documents column and row template behavior shared by both:

  • named templates loaded through et2-nextmatch template="app.index.rows"
  • slotted templates provided directly to et2-nextmatch

Columns

Columns are derived from header widgets/elements and include key, title, and optional width/minWidth/disabled metadata.

From Named Templates

When using et2-nextmatch template="app.index.rows":

  • Header definition is parsed from the template header row (.th, thead, or grid header structure).
  • Column widgets (such as et2-nextmatch-header, et2-nextmatch-sortheader) are used to build column definitions.
  • Legacy Nextmatch visibility/size preferences are mapped and applied by et2-nextmatch.

From Slotted Templates

(WIP) When using slots (template attribute not set):

  • Columns come from slot="columns".
  • Any wrapper can carry the slot (tr, div, et2-box, etc.).
  • The columns wrapper itself is not treated as a column; its child elements are used as column definitions.

Example:

<tr class="th" slot="columns">
    <et2-nextmatch-sortheader id="n_family" label="Name"></et2-nextmatch-sortheader>
    <et2-nextmatch-header id="note" label="Note"></et2-nextmatch-header>
    <et2-vbox>
        <et2-nextmatch-header id="tel_work" label="Business phone"></et2-nextmatch-header>
        <et2-nextmatch-header id="tel_cell" label="Mobile phone"></et2-nextmatch-header>
        <et2-nextmatch-header id="tel_home" label="Home phone"></et2-nextmatch-header>
    </et2-vbox>
</tr>

Rows

Row rendering is driven by a row template.
:::note

  • The row template is not given any server-side processing when the template is initially loaded.
  • Avoid legacy widgets in the row template. :::

Field expression support in row templates:

  • Legacy: ${row}[note], $row_cont[note]
  • Shorthand: ${note}, $note

Both work. For new templates, shorthand is recommended for readability.

From Named Templates

Named row templates are normalized from legacy eTemplate structures (<row>) into datagrid renderable markup. Common legacy patterns continue to work.

From Slotted Templates

(WIP) Slotted row template comes from slot="row".

  • Preferred wrapper: <tr slot="row">
  • Legacy wrapper: <row slot="row">
  • Any other wrapper is preserved as-is (for example <sl-card slot="row">)

If the wrapper is <tr> or <row>, bare child widgets are allowed and are auto-wrapped into <td> cells.

Example:

<tr class="$class $cat_id" slot="row">
    <et2-description id="${n_family}" noLang="1"></et2-description>
    <et2-textarea id="${note}" readonly="true" noLang="1"></et2-textarea>
    <et2-vbox>
        <et2-url-phone id="${tel_work}" 
           readonly="true" class="telNumbers" statustext="Business phone"
        ></et2-url-phone>
        <et2-url-phone id="${tel_cell}" 
           readonly="true" class="telNumbers" statustext="Mobile phone"
        ></et2-url-phone>
        <et2-url-phone id="${tel_home}" 
           readonly="true" class="telNumbers" statustext="Home phone"
        ></et2-url-phone>
    </et2-vbox>
</tr>

Loader Template

Optional placeholder template while rows are loading:

  • slot="loader" (preferred)

Any wrapper can be used for loader slot content.

Example:

<tr slot="loader">
    <td colspan="2">
        <sl-skeleton effect="sheen" style="width:100%"></sl-skeleton>
    </td>
</tr>

No-Results Template

Optional template shown when loading is complete and no rows are available:

  • Replaces the default no-results <sl-alert> entirely

Example:

<sl-alert slot="noResults" variant="neutral" open>
    <sl-icon slot="icon" name="inbox"></sl-icon>
    <strong>This mailbox is empty</strong>
</sl-alert>

Properties

Name Description Reflects Type Default
accesskey Accesskey provides a hint for generating a keyboard shortcut for the current element. The attribute value must consist of a single printable character. string -
actions Set Actions on the widget Each action is defined as an object: move: { type: “drop”, acceptedTypes: “mail”, icon: “move”, caption: “Move to” onExecute: javascript:mail_move” } This will turn the widget into a drop target for “mail” drag types. When “mail” drag types are dropped, the global function mail_move(egwAction action, egwActionObject sender) will be called. The ID of the dragged “mail” will be in sender.id, some information about the sender will be in sender.context. The etemplate2 widget involved can typically be found in action.parent.data.widget, so your handler can operate in the widget context easily. The location varies depending on your action though. It might be action.parent.parent.data.widget To customise how the actions are handled for a particular widget, override _link_actions(). It handles the more widget-specific parts. object -
align Used by Et2Box to determine alignment. Allowed values are left, right string -
class CSS Class. This class is applied to the outside, on the web component itself. Due to how WebComponents work, this might not change anything inside the component. string -
columnPreferenceName
column-preference-name
Optional explicit preference key for persisted column state. When omitted, datagrid derives key from owner component + row template id. string ""
columns
Visible column configuration, including sizing and optional hide expressions. Et2DatagridColumn[] []
configurationLoading
configuration-loading
External loading flag for configuration/template setup before first data render. boolean false
data Set the dataset from a CSV string -
dataProvider
Paging adapter used by infinite scroll to fetch additional rows from the server. Et2DatagridDataProvider | null null
deferredProperties
Any attribute that refers to row content cannot be resolved immediately, but some like booleans cannot stay a string because it’s a boolean attribute. We store them for later, and parse when they’re fully in their row. If you are creating a widget that can go in a nextmatch row, and it has boolean attributes that can change for each row, add those attributes into deferredProperties - -
disabled Defines whether this widget is visibly disabled. The widget is still visible, but clearly cannot be interacted with. Widgets disabled in the template will not return a value to the application code, even if re-enabled via javascript before submitting. To allow a disabled widget to be re-enabled and return a value, disable via javascript in the app’s et2_ready() instead of an attribute in the template file. boolean false
dom_id
Get the actual DOM ID, which has been prefixed to make sure it’s unique. string -
emptyStateText
empty-state-text
Optional replacement for the default empty-state headline text. Keeps default empty-state template structure while allowing Nextmatch-level customization. string ""
fetchErrorMessage
Optional provider error message shown in error state. string ""
fetchFailed
Error state set when the latest fetch failed. boolean false
fetching
Guard flag used to prevent overlapping fetchPage() calls. boolean false
hidden The widget is not visible. As far as the user is concerned, the widget does not exist. Widgets hidden with an attribute in the template may not be created in the DOM, and will not return a value. Widgets can be hidden after creation, and they may return a value if hidden this way. boolean -
id
Get the ID of the widget string -
label The label of the widget This is usually displayed in some way. It’s also important for accessability. This is defined in the parent somewhere, and re-defining it causes labels to disappear string -
loading
True while a fetch cycle is active, including initial and incremental page loads. boolean false
noColumnSelection Hide the column chooser action in the header when true. boolean false
noLang Disable any translations for the widget boolean -
pageSize Maximum number of rows requested per page load. number 50
parentId Parent is different than what is specified in the template / hierarchy. Widget ID of another node to insert this node into instead of the normal location string -
rowCustomizer
Optional hook invoked for each realized row to customize row/meta-cell presentation. Et2DatagridRowCustomizer | null null
rows
Rows currently materialized in the DOM/in-memory list. Et2DatagridRow[] []
selectionMode
selection-mode
Row selection behavior: none, single, or multiple. Et2DatagridSelectionMode "multiple"
statustext Tooltip which is shown for this element on hover string -
styles
WebComponent * - -
templateData
Prepared template and metadata used to render each row. Et2DatagridTemplateData | null null
total
Total row count reported by provider, or null when unknown. number | null null
options
Get property-values as object
use widget methods
object -
supportedWidgetClasses
et2_widget compatability
Legacy compatability. Some legacy widgets check their parent to see whats allowed
array []
updateComplete A read-only promise that resolves when the component has finished updating.

Learn more about attributes and properties.

Events

Name React Event Description Event Detail
et2-loading-error Fired when a row fetch request fails. CustomEvent
et2-loading-done Fired when all in-flight row fetch requests complete successfully. CustomEvent
et2-loading-start Fired when one or more row fetch requests are dispatched. CustomEvent
et2-columns-changed Fired when column order, width, or visibility changes. CustomEvent
et2-selection-changed Fired when row selection changes. CustomEvent

Learn more about events.

Methods

Name Description Arguments
checkCreateNamespace() Checks whether a namespace exists for this element in the content array. If yes, an own perspective of the content array is created. If not, the parent content manager is used. Constructor attributes are passed in case a child needs to make decisions -
clear() Reset all grid runtime state including selection and fetch markers. -
clone() Creates a copy of this widget. _parent: et2_widget
createElementFromNode() Create a et2_widget from an XML node. First the type and attributes are read from the node. Then the readonly & modifications arrays are checked for changes specific to the loaded data. Then the appropriate constructor is called. After the constructor returns, the widget has a chance to further initialize itself from the XML node when the widget’s loadFromXML() method is called with the node. _node: , _name:
getArrayMgr() Returns the array manager object for the given part managed_array_type: string
getArrayMgrs() Returns an associative array containing the top-most array managers. _mgrs: object
getChildren() Get child widgets Use .children to get web component children -
getInstanceManager() Returns the instance manager -
getPath() Returns the path into the data array. By default, array manager takes care of this, but some extensions need to override this -
getRoot() Returns the base widget Usually this is the same as getInstanceManager().widgetContainer -
loadFromXML() Loads the widget tree from an XML node _node:
loadingFinished() Needed for legacy compatability. promises: Promise[]
loadMore() Trigger next page load when allowed by current state. -
parseXMLAttrs() The parseXMLAttrs function takes an XML DOM attributes object and adds the given attributes to the _target associative array. This function also parses the legacyOptions. N.B. This is only used for legacy widgets. WebComponents use transformAttributes() and do their own handling of attributes. _attrsObj: , _target: object, _proto: et2_widget
refresh() Apply a targeted row refresh without forcing a full grid reload. The provider decides which rows changed or disappeared; the datagrid only updates rows it already has materialized locally. row_ids: string[], type: Et2DatagridUpdateType
reload() Clear current rows and load from first page. -
selectSingleRow() Select exactly one row by id and synchronize visual/accessibility state. rowId: string
set_label() NOT the setter, since we cannot add to the DOM before connectedCallback() TODO: This is not best practice. Should just set property, DOM modification should be done in render https://lit-element.polymer-project.org/guide/templates#design-a-performant-template value: string
setArrayMgr() Sets the array manager for the given part _part: string, _mgr: object
setArrayMgrs() Sets all array manager objects - this function can be used to set the root array managers of the container object. _mgrs: object
setInitialRows() Seed datagrid with preloaded rows and skip initial fetch. rows: any[]
setInstanceManager() Set the instance manager Normally this is not needed as it’s set on the top-level container, and we just return that reference manager: etemplate2
_get_action_links() Get all action-links / id’s of 1.-level actions from a given action object This can be overwritten to not allow all actions, by not returning them here. actions:
_handleClick() Click handler calling custom handler set via onclick attribute to this.onclick _ev: MouseEvent
_handleColumnSelectionClick() Handle column selection action from the header button. event: MouseEvent
_headerTemplate() Render the visible column header row (or fallback header slot). visibleColumns: Et2DatagridColumn[]
_link_actions() Link the actions to the DOM nodes / widget bits. actions: object
_set_label() Do some fancy stuff on the label, splitting it up if there’s a %s in it Normally called from updated(), the “normal” setter stuff has already been run before this is called. We only override our special cases (%s) because the normal label has been set by the parent value: string
destroy() et2_widget compatability
true
-
set_class() Set the widget class
Use this.class or this.classList instead
new_class: string
set_disabled() Wrapper on this.disabled because legacy had it.
Use widget.disabled for visually disabled, widget.hidden for visually hidden. Disabled vs Readonly vs Hidden
value: boolean
set_statustext() supports legacy set_statustext
use this.statustext
value: string

Learn more about methods.

Custom Properties

Name Description Default
--row-height Estimated row height used for spacer rendering. 3em
--meta-column-width Width of leading metadata column. 0px
--column-sizes Grid-template column track definition used by header/body rows.
--column-count Column count fallback when explicit track sizes are not set. 1
--scrollbar-space Reserved right-side space in header for body scrollbar alignment. 15px

Learn more about customizing CSS custom properties.

Parts

Name Description
base Root wrapper around the grid header and body.
header Visible column header row container.
body Scrollable container for state content and table.
state State message container (loading, empty, template missing, or fetch error).
resize-helper Helper bar shown while resizing a column.
table Internal table element with ARIA grid semantics.
rows Table body that hosts virtualized row content.
meta-column Leading header column used for row metadata indicators.
row-meta Leading per-row metadata cell (column 0), customizable by consumers.
column A visible header column wrapper.
column-selection Column selection action container in the header.

Learn more about customizing CSS parts.