FleetbaseFleetbase

Table

<Table> is the standard data table component — sortable, resizable, selectable, expandable, with pagination support and pluggable cell components.

<Table>

<Table> is the standard data table for resource lists. It supports sortable columns, resizable columns, row selection (single and bulk), expandable rows, custom cell components, and pagination.

For full resource pages with search, filters, and bulk actions, prefer <Layout::Resource::Tabular> — it's a higher-level wrapper around <Table>.

Basic Usage

<Table @rows={{this.rows}} @columns={{this.columns}} @onRowClick={{this.openRow}} />
columns = [
  { label: 'ID',     valuePath: 'public_id', sortable: true,  width: '120px' },
  { label: 'Name',   valuePath: 'name',      sortable: true },
  { label: 'Status', valuePath: 'status',    cellComponent: 'table/cell/status' },
  { label: '',       cellComponent: 'table/cell/dropdown', cellComponentArgs: { actions: this.rowActions } },
];

Column Descriptors

Each column is a plain object with these fields:

FieldTypeDescription
labelstringColumn header text
valuePathstringDot-path on the row to display
widthstringCSS width (e.g. 120px, 15%)
sortablebooleanAllow sorting by this column
resizablebooleanAllow drag-resizing
filterablebooleanShow in the filters picker
cellComponentstringResolution path for a custom cell renderer
cellComponentArgsobjectArgs forwarded to the cell component
headerComponentstringCustom header renderer
hiddenbooleanHidden by default; surfaces in the column picker
permanentbooleanCannot be hidden via the column picker
cellClass, headerClassstringClass hooks

Row Selection

<Table
  @rows={{this.rows}}
  @columns={{this.columns}}
  @selectable={{true}}
  @canSelectAll={{true}}
  @onRowClick={{this.openRow}}
/>

Read table.selectedRows from the captured table instance to power bulk actions.

Expandable Rows

<Table @rows={{this.rows}} @columns={{this.columns}} @canExpand={{true}}>
  <:expandedRow as |row|>
    {{!-- arbitrary expanded content --}}
    <DriverDetails @driver={{row}} />
  </:expandedRow>
</Table>

Pagination

<Table
  @rows={{this.rows}}
  @columns={{this.columns}}
  @pagination={{true}}
  @paginationMeta={{this.paginationMeta}}
  @page={{this.page}}
  @onPageChange={{fn (mut this.page)}}
  @insertPagination={{true}}
  @useTfootPagination={{true}}
/>

Arguments

Core

ArgumentDescription
@rowsRow data (array)
@columnsColumn descriptors
@onRowClick(row, event) — row click handler
@onSetupCaptures the table API
@wrapperClassOuter wrapper class
@selectableEnable per-row checkboxes
@canSelectAllEnable a "select all" checkbox in the header
@checkboxStickySticky position for the select-all column
@selectAllColumnWidthWidth of the select-all column (default 40)

Expansion

ArgumentDescription
@canExpandEnable expandable rows
:expandedRow named blockYields the row to render inside the expansion

Pagination

ArgumentDescription
@paginationShow pagination
@paginationMeta{ total, perPage, lastPage, currentPage }
@pageCurrent page
@onPageChangePage change callback
@insertPaginationRender the pagination row
@useTfootPaginationRender pagination in <tfoot>

Cell Components

<Table> ships with several stock cell components. Reference them in cellComponent:

PathRenders
table/cell/anchorClickable link
table/cell/checkboxCheckbox
table/cell/dropdownAction dropdown menu
table/cell/status<Badge> for the status
table/cell/click-to-copyCopyable value
table/cell/click-to-revealHidden-then-revealable value
table/cell/mediaImage preview
table/cell/datetimeFormatted date
table/cell/moneyFormatted money
table/cell/componentGeneric — pass any component name in cellComponentArgs

You can also point cellComponent at any component in your extension.

Real-World Example

<Table
  @rows={{this.drivers}}
  @columns={{array
    (hash label="ID" valuePath="public_id" sortable=true cellComponent="table/cell/click-to-copy")
    (hash label="Name" valuePath="name" sortable=true)
    (hash label="Status" valuePath="status" cellComponent="table/cell/status")
    (hash label="" cellComponent="table/cell/dropdown" cellComponentArgs=(hash actions=this.rowActions))
  }}
  @selectable={{true}}
  @canSelectAll={{true}}
  @pagination={{true}}
  @paginationMeta={{this.paginationMeta}}
  @onPageChange={{fn (mut this.page)}}
  @onRowClick={{this.openDriver}}
/>

See Also

  • <Layout::Resource::Tabular> — full resource page wrapper
  • <VisibleColumnPicker> — let users hide/show columns
  • <Pagination> — standalone pagination component

Source

FileDescription
addon/components/table.hbsTemplate
addon/components/table.jsClass
addon/components/table/Head, body, row, th, td, and all cell renderers
Table | Fleetbase