Interface TableModel<IdType>

Represents the state of table UI. It grants access to the formatted table data.

You can watch the properties columns, filterBy, sortBy, total, state and loadError for changes.

 const dataset = ...;
dataset.watch("state", ({value})=> {
const newState = value;
//newState can be: "disconnected" | "loading" | "loaded" | "load-error"
});

You can watch for the events selection-changed, focus-changed, rows-changed and destroyed.

const dataset = ...;
dataset.on("selection-changed", ({added, deleted })=> { ... });
dataset.on("focus-changed", ({focusedItemId})=> { ... });
dataset.on("rows-changed", ()=> { ... });
dataset.on("destroyed",()=> { ... });
interface TableModel<IdType> {
    clearSelection(): void;
    clickItem(datasetItemId): void;
    columns: readonly Column[];
    connect(): void;
    convertDatasetItemToRow(dataSetItem, formatterOptionsOverrides?): RowItem<IdType>;
    dataset: Dataset<IdType>;
    deselect(datasetItemIds): void;
    destroy(): void;
    disconnect(): void;
    filterBy: undefined | SuggestFilter;
    focusItem(datasetItemId): void;
    getAllSelectedItems(): Promise<TableItem<IdType>[]>;
    getRowItem(datasetItemId): undefined | TableItem<IdType>;
    getRows(startIndex?, count?): readonly RowItem<IdType>[];
    getSelectedCount(): number;
    getSelectedIds(): IdType[];
    getSelectedItems(): AsyncIterable<TableItem<IdType>>;
    hasSelectedIds(): boolean;
    invertSelectionOfAllItems(): Promise<void>;
    invertSelectionOfAvailableRows(): Promise<void>;
    isSelectedId(datasetItemId): boolean;
    loadError: undefined | Error;
    on<Name>(name, callBack): Handle;
    refresh(): void;
    select(datasetItemIds, selected?): void;
    selectAllAvailableRows(): Promise<void>;
    selectAllItems(): Promise<void>;
    setVisibleColumns(names?): void;
    sortBy: SortSpecifier[];
    state: TableModelState;
    total: number;
}

Type Parameters

Hierarchy

Properties

columns: readonly Column[]

Columns of the table.

dataset: Dataset<IdType>

The dataset associated with the table.

filterBy: undefined | SuggestFilter

Filter state.

loadError: undefined | Error

Load error if state === "load-error".

sortBy: SortSpecifier[]

Sort state.

State of the table.

total: number

Total number of items of the last query.

Methods

  • Clears the selection.

    Returns void

  • Emits a row-clicked event.

    Parameters

    • datasetItemId: IdType

      id of row item.

    Returns void

  • Connect this table to the dataset. The UI may use this to ensure that a table observes dataset changes.

    Returns void

  • Provides access to the data to display conversion code. It converts a DatasetItem into a Row. A row has column values, which are prepared to be displayed in table UI. The column values are field data transformed by Formatters. This method allows data conversion for dataset items currently not displayed in the table. E.g. for CSV Export.

    Parameters

    • dataSetItem: TableItem<IdType>

      the item to transform

    • Optional formatterOptionsOverrides: FormatterOptions

      Options how to format the output. Can be used to override formatting of columns. For example used to control the formatting of numeric values when exported as csv.

    Returns RowItem<IdType>

  • Removes all given values from the selection.

    Parameters

    • datasetItemIds: Iterable<IdType>

      iterable of values.

    Returns void

  • Destroys this table model.

    Returns void

  • Disconnect this table from the dataset. The UI may use this to prevent unnecessary updates as long as the table is not shown.

    Returns void

  • Sets the focus to the given item. If datasetItemId is undefined, the focus is removed from the item.

    Parameters

    • datasetItemId: undefined | IdType

    Returns void

  • Provides a way to fetch all selected items. Behaves like getSelectedItems but provides a Promise with all items as an array. A selected item may not directly be part of the rows.

    Returns Promise<TableItem<IdType>[]>

  • Provides a way to get access to the dataset item referenced by the row. Note this item will have only the fields required by the table.

    Parameters

    • datasetItemId: IdType

      id of a dataset item.

    Returns undefined | TableItem<IdType>

  • Gets currently fetched rows. Should only be accessed if table is in state "loaded".

    Parameters

    • Optional startIndex: number

      pagination start index.

    • Optional count: number

      pagination size (page size)

    Returns readonly RowItem<IdType>[]

  • Amount of selected items.

    Returns number

  • Provides access to all selected ids.

    Returns IdType[]

  • Provides a way to fetch all selected items. A selected item may not directly be part of the rows.

    Returns AsyncIterable<TableItem<IdType>>

  • true = selected items available. false = no item selected.

    Returns boolean

  • Inverts the selection of all available items in the dataset.

    Returns Promise<void>

  • Inverts the selection, reduced to currently available rows.

    Returns Promise<void>

  • Parameters

    Returns boolean

    a boolean indicating whether the given id is selected.

  • Enforce a refresh of the rows.

    Returns void

  • Adds all values to the selection.

    Parameters

    • datasetItemIds: Iterable<IdType>

      iterable of values.

    • Optional selected: boolean

      true == select, false === deselect. If omitted this is interpreted as true.

    Returns void

  • Selects all currently available rows.

    Returns Promise<void>

  • Selects all items available in the dataset.

    Returns Promise<void>

  • Limits the columns returned by the columns property to those having one of the specified names.

    Parameters

    • Optional names: string[]

      names of columns to be returned by the columns property, or undefined to let it return all columns.

    Returns void

Generated using TypeDoc