map.apps Bundle APIs 4.20.2
    Preparing search index...

    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 extends DatasetItemId = DatasetItemId> {
        clearSelection(): void;
        clickItem(datasetItemId: IdType): void;
        columns: readonly Column[];
        connect(): void;
        convertDatasetItemToRow(
            dataSetItem: TableItem<IdType>,
            formatterOptionsOverrides?: FormatterOptions,
        ): RowItem<IdType>;
        dataset: Dataset<IdType>;
        deselect(datasetItemIds: Iterable<IdType>): void;
        destroy(): void;
        disconnect(): void;
        filterBy: SuggestFilter | undefined;
        focusItem(datasetItemId: IdType | undefined): void;
        getAllSelectedItems(): Promise<TableItem<IdType>[]>;
        getRowItem(datasetItemId: IdType): TableItem<IdType> | undefined;
        getRows(startIndex?: number, count?: number): readonly RowItem<IdType>[];
        getSelectedCount(): number;
        getSelectedIds(): IdType[];
        getSelectedItems(): AsyncIterable<TableItem<IdType>>;
        hasSelectedIds(): boolean;
        invertSelectionOfAllItems(): Promise<void>;
        invertSelectionOfAvailableRows(): Promise<void>;
        isSelectedId(datasetItemId: IdType): boolean;
        loadError: Error | undefined;
        on<Name extends keyof TableModelEvents<IdType>>(
            name: Name,
            callBack: EventCallback<TableModelEvents<IdType>[Name]>,
        ): Handle;
        refresh(): void;
        rowAriaLabel: string;
        select(datasetItemIds: Iterable<IdType>, selected?: boolean): void;
        selectAllAvailableRows(): Promise<void>;
        selectAllItems(): Promise<void>;
        setVisibleColumns(names?: string[]): void;
        sortBy: SortSpecifier[];
        state: TableModelState;
        total: number;
    }

    Type Parameters

    Hierarchy

    Index

    Properties

    columns: readonly Column[]

    Columns of the table.

    dataset: Dataset<IdType>

    The dataset associated with the table.

    filterBy: SuggestFilter | undefined

    Filter state.

    loadError: Error | undefined

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

    rowAriaLabel: string

    The aria label of a row of the table. This is a string like Text: ${columnName}. The default UI attaches it as meta information to a row.

    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

      • OptionalformatterOptionsOverrides: 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: IdType | undefined

      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 TableItem<IdType> | undefined

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

      Parameters

      • OptionalstartIndex: number

        pagination start index.

      • Optionalcount: 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.

      • Optionalselected: 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

      • Optionalnames: string[]

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

      Returns void