addSubRows

addSubRows defines the data for deriving the sub-rows of a row. Often used with addExpandedRows to visualize sub-rows.

The id of a sub-row is in the format {parentId}>{id}. Nested sub-rows concatenate parent ids to the top-level row id.

Options

Information:
Options passed into addSubRows.
const table = createTable(data, {
  sub: addSubRows({ ... }),
});
const table = createTable(data, {
  sub: addSubRows({ ... }),
});

children: string | (item) => Item[]

Define child items: either a string property on each data item or a function returning an array of child items.

If children is missing or returns [], no sub-rows are generated for that row.

Column Options

Information:
Options passed into column definitions.
const columns = table.createColumns([
  table.column({
    header: 'Name',
    accessor: 'name',
    plugins: {
      sub: { ... },
    },
  }),
]);
const columns = table.createColumns([
  table.column({
    header: 'Name',
    accessor: 'name',
    plugins: {
      sub: { ... },
    },
  }),
]);

Prop Set

Information:
Extensions to the view model. Read current.props on table components.
{#each vm.current.headerRows as headerRow (headerRow.id)}
  {headerRow.current.props.sub}
  {#each headerRow.cells as cell (cell.id)}
    {cell.current.props.sub}
  {/each}
{/each}
{#each vm.current.headerRows as headerRow (headerRow.id)}
  {headerRow.current.props.sub}
  {#each headerRow.cells as cell (cell.id)}
    {cell.current.props.sub}
  {/each}
{/each}

Plugin interactions

  • addSortBy: before => all sub-rows sorted within groups; after => only top-level sorted.
  • addColumnFilters: before => sub-rows are searched; after => only top-level rows searched.
  • addTableFilter: similarly affects whether sub-rows are searched.