1. Plugins
  2. addHiddenColumns

Plugins

addHiddenColumns

addHiddenColumns hides table columns dynamically.

Options

Options passed into addHiddenColumns.

const table = createTable(data, {
  hide: addHiddenColumns({ ... }),
});

initialHiddenColumnIds?: string[]

Sets the initial hidden column ids.

Defaults to [].

Column Options

Options passed into column definitions.

const columns = table.createColumns([
  table.column({
    header: 'Name',
    accessor: 'name',
    plugins: {
      hide: { ... },
    },
  }),
]);

Nothing here so far.

Prop Set

Extensions to the view model.

Subscribe to .props() on the respective table components.

{#each $headerRows as headerRow (headerRow.id)}
  <Subscribe rowProps={headerRow.props()} let:rowProps>
    {rowProps.hide} <!-- HeaderRow props -->
    {#each headerRow.cells as cell (cell.id)}
      <Subscribe props={cell.props()} let:props>
        {props.hide} <!-- HeaderCell props -->
      </Subscribe>
    {/each}
  </Subscribe>
{/each}

Nothing here so far.

Plugin State

State provided by addHiddenColumns.

const { headerRows, rows, pluginStates } = table.createViewModel(columns);
const { ... } = pluginStates.hide;

hiddenColumnIds: Writable<string[]>

The active hidden column ids.

Examples

Simple hidden columns