@timlassiter11/yatl
    Preparing search index...

    Class YatlTableController<T>

    Type Parameters

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Accessors

    • get columnOrder(): NestedKeyOf<T>[]

      The explicit, raw visual layout intent for the table's columns. This property acts as the pure state record. It is strictly symmetrical: reading this property will return the exact array of field names that was most recently set, preserving the user's or developer's exact layout preference.

      • Use this property when exporting or saving the table's layout state (e.g., to localStorage or a database).
      • Note: Because this represents intent rather than computed reality, it may contain fields that are no longer defined, or omit newly added fields. If you need the exact array of columns currently rendered on the screen, use displayColumns instead.

      Returns NestedKeyOf<T>[]

    • set columnOrder(value: NestedKeyOf<T>[]): void

      The explicit, raw visual layout intent for the table's columns. This property acts as the pure state record. It is strictly symmetrical: reading this property will return the exact array of field names that was most recently set, preserving the user's or developer's exact layout preference.

      • Use this property when exporting or saving the table's layout state (e.g., to localStorage or a database).
      • Note: Because this represents intent rather than computed reality, it may contain fields that are no longer defined, or omit newly added fields. If you need the exact array of columns currently rendered on the screen, use displayColumns instead.

      Parameters

      Returns void

    • get displayColumns(): DisplayColumnOptions<T>[]

      The computed, fully-resolved array of columns intended for visual rendering. This is a derived View Model. It takes the explicit columnOrder intent and reconciles it against the actual columns definitions. It safely handles newly added columns, filters out undefined fields, and guarantees a strictly-typed array representing the exact left-to-right visual layout of the data grid. This property is intended for template rendering and internal layout math (such as drag-and-drop boundary calculations). To programmatically mutate the column layout, set the columnOrder property or use the moveColumn() API.

      Returns DisplayColumnOptions<T>[]

    • get filters(): Partial<{ [K in string]: unknown }> | null

      An optional set of criteria to filter the visible rows. This runs before the global search query is applied. *

      Returns Partial<{ [K in string]: unknown }> | null

      // Shows rows where status is 'active' AND role is 'admin'
      table.filters = { status: 'active', role: 'admin' };
    • set filters(filters: Partial<{ [K in string]: unknown }> | null): void

      An optional set of criteria to filter the visible rows. This runs before the global search query is applied. *

      Parameters

      • filters: Partial<{ [K in string]: unknown }> | null

      Returns void

      // Shows rows where status is 'active' AND role is 'admin'
      table.filters = { status: 'active', role: 'admin' };
    • get filterStrategy(): FilterCallback<T> | null

      An optional custom filter function. Provide this function to bypass the default filter logic.

      Returns FilterCallback<T> | null

      true to keep the row in the filteredData results, false to exclude it.

      controller.filterStrategy = (row, filters) => {
      // Example: Custom global search across multiple columns
      if (filters.globalSearch) {
      const term = filters.globalSearch.toLowerCase();
      if (
      !row.firstName.toLowerCase().includes(term) &&
      !row.lastName.toLowerCase().includes(term)
      ) {
      return false;
      }
      }
      // Example: Strict mathematical matching
      if (filters.minAge && row.age < filters.minAge) {
      return false;
      }
      return true;
      };
    • set filterStrategy(value: FilterCallback<T> | null): void

      An optional custom filter function. Provide this function to bypass the default filter logic.

      Parameters

      Returns void

      true to keep the row in the filteredData results, false to exclude it.

      controller.filterStrategy = (row, filters) => {
      // Example: Custom global search across multiple columns
      if (filters.globalSearch) {
      const term = filters.globalSearch.toLowerCase();
      if (
      !row.firstName.toLowerCase().includes(term) &&
      !row.lastName.toLowerCase().includes(term)
      ) {
      return false;
      }
      }
      // Example: Strict mathematical matching
      if (filters.minAge && row.age < filters.minAge) {
      return false;
      }
      return true;
      };
    • get rowIdCallback(): RowIdCallback<T> | undefined

      A callback function used to extract or generate a unique identifier for each row.

      A stable, unique ID is heavily relied upon by the grid engine for maintaining row selection state, tracking row metadata, and ensuring optimal rendering performance within the virtual scroller—especially when data is actively being sorted, filtered, or updated.

      Default Behavior: * If not provided, the table will automatically attempt to locate an id, key, or _id property on the row data object. If none are found, it falls back to using the row's original array index (which will trigger a console warning, as indices are inherently unstable during sorting).

      Note: Because this expects a JavaScript function, it is exposed strictly as a property and does not have a corresponding HTML attribute. You must use the property binding syntax (.rowIdCallback) in a Lit template.

      Returns RowIdCallback<T> | undefined

      * <yatl-table .rowIdCallback=${(row) => row.deviceUuid}></yatl-table>
      
      // Programmatic assignment using a composite key
      table.rowIdCallback = (row, index) => `${row.chassisId}-${row.slotNumber}`;
    • set rowIdCallback(callback: RowIdCallback<T> | undefined): void

      A callback function used to extract or generate a unique identifier for each row.

      A stable, unique ID is heavily relied upon by the grid engine for maintaining row selection state, tracking row metadata, and ensuring optimal rendering performance within the virtual scroller—especially when data is actively being sorted, filtered, or updated.

      Default Behavior: * If not provided, the table will automatically attempt to locate an id, key, or _id property on the row data object. If none are found, it falls back to using the row's original array index (which will trigger a console warning, as indices are inherently unstable during sorting).

      Note: Because this expects a JavaScript function, it is exposed strictly as a property and does not have a corresponding HTML attribute. You must use the property binding syntax (.rowIdCallback) in a Lit template.

      Parameters

      Returns void

      * <yatl-table .rowIdCallback=${(row) => row.deviceUuid}></yatl-table>
      
      // Programmatic assignment using a composite key
      table.rowIdCallback = (row, index) => `${row.chassisId}-${row.slotNumber}`;
    • get storageOptions(): | {
          key: string;
          saveColumnOrder?: boolean;
          saveColumnSortOrders?: boolean;
          saveColumnStickyPositions?: boolean;
          saveColumnVisibility?: boolean;
          saveColumnWidths?: boolean;
          saveSearchQuery?: boolean;
          saveSelectedRows?: boolean;
          storage?: StorageInterface;
      }
      | null

      Configuration options for automatically saving and restoring table state (column width, order, visibility, etc.) to the provided storage interface.

      Returns
          | {
              key: string;
              saveColumnOrder?: boolean;
              saveColumnSortOrders?: boolean;
              saveColumnStickyPositions?: boolean;
              saveColumnVisibility?: boolean;
              saveColumnWidths?: boolean;
              saveSearchQuery?: boolean;
              saveSelectedRows?: boolean;
              storage?: StorageInterface;
          }
          | null

      • {
            key: string;
            saveColumnOrder?: boolean;
            saveColumnSortOrders?: boolean;
            saveColumnStickyPositions?: boolean;
            saveColumnVisibility?: boolean;
            saveColumnWidths?: boolean;
            saveSearchQuery?: boolean;
            saveSelectedRows?: boolean;
            storage?: StorageInterface;
        }
        • key: string

          The unique key used to store the table state in the browser. *

          "my-app-users-table-v1"
          
        • OptionalsaveColumnOrder?: boolean

          Save the current order of columns

        • OptionalsaveColumnSortOrders?: boolean

          Save the current column sorting

        • OptionalsaveColumnStickyPositions?: boolean

          Save the current column sticky positions

        • OptionalsaveColumnVisibility?: boolean

          Save the current column visibility

        • OptionalsaveColumnWidths?: boolean

          Save the current column widths

        • OptionalsaveSearchQuery?: boolean

          Save the current search query

        • OptionalsaveSelectedRows?: boolean

          Save the currently selected rows

        • Optionalstorage?: StorageInterface

          A storage client for getting and setting values. Defaults to window.localStorage

      • null
    • set storageOptions(
          options:
              | {
                  key: string;
                  saveColumnOrder?: boolean;
                  saveColumnSortOrders?: boolean;
                  saveColumnStickyPositions?: boolean;
                  saveColumnVisibility?: boolean;
                  saveColumnWidths?: boolean;
                  saveSearchQuery?: boolean;
                  saveSelectedRows?: boolean;
                  storage?: StorageInterface;
              }
              | null,
      ): void

      Configuration options for automatically saving and restoring table state (column width, order, visibility, etc.) to the provided storage interface.

      Parameters

      • options:
            | {
                key: string;
                saveColumnOrder?: boolean;
                saveColumnSortOrders?: boolean;
                saveColumnStickyPositions?: boolean;
                saveColumnVisibility?: boolean;
                saveColumnWidths?: boolean;
                saveSearchQuery?: boolean;
                saveSelectedRows?: boolean;
                storage?: StorageInterface;
            }
            | null
        • {
              key: string;
              saveColumnOrder?: boolean;
              saveColumnSortOrders?: boolean;
              saveColumnStickyPositions?: boolean;
              saveColumnVisibility?: boolean;
              saveColumnWidths?: boolean;
              saveSearchQuery?: boolean;
              saveSelectedRows?: boolean;
              storage?: StorageInterface;
          }
          • key: string

            The unique key used to store the table state in the browser. *

            "my-app-users-table-v1"
            
          • OptionalsaveColumnOrder?: boolean

            Save the current order of columns

          • OptionalsaveColumnSortOrders?: boolean

            Save the current column sorting

          • OptionalsaveColumnStickyPositions?: boolean

            Save the current column sticky positions

          • OptionalsaveColumnVisibility?: boolean

            Save the current column visibility

          • OptionalsaveColumnWidths?: boolean

            Save the current column widths

          • OptionalsaveSearchQuery?: boolean

            Save the current search query

          • OptionalsaveSelectedRows?: boolean

            Save the currently selected rows

          • Optionalstorage?: StorageInterface

            A storage client for getting and setting values. Defaults to window.localStorage

        • null

      Returns void

    Methods

    • Finds the original index of the first row where the specified field matches the given value. This searches through the original, unfiltered dataset.

      Parameters

      • field: NestedKeyOf<T>

        The field name within the row data to search.

      • value: unknown

        The value to match against the field's content.

      Returns number

      The original index of the found row, or -1 if no match is found.

      const index = dataTable.indexOf('id', 12345);
      if (index >= 0) {
      dataTable.updateRow({description: "Updated description"}, index);
      }
    • Called when the host is connected to the component tree. For custom element hosts, this corresponds to the connectedCallback() lifecycle, which is only called when the component is connected to the document.

      Returns void

    • Called when the host is disconnected from the component tree. For custom element hosts, this corresponds to the disconnectedCallback() lifecycle, which is called the host or an ancestor component is disconnected from the document.

      Returns void

    • Called during the client-side host update, just before the host calls its own update.

      Code in update() can depend on the DOM as it is not called in server-side rendering.

      Returns void

    • Updates the data of a row at a specific original index.

      Parameters

      • index: number

        The original index of the row to update.

      • data: Partial<T>

        An object containing the new data to assign to the row. Existing fields will be updated, and new fields will be added.

      Returns void

      const index = dataTable.indexOf('id', 12345);
      if (index >= 0) {
      dataTable.updateRow(index, {description: "Updated description"});
      }