Adaptable

#Infinite Table Integration

Adaptable renders its grid with Infinite Table: <adaptable-data-grid> (part of <adaptable-ui>) renders an InfiniteTable inside a DataSource, with props computed from the Adaptable state. For most apps the Adaptable API is all you need. For advanced cases you can reach the engine in two ways:

  • Replace the InfiniteTable and DataSource components Adaptable renders, to add props or intercept callbacks.
  • Get the raw Infinite Table APIs.
Warning

Both are escape hatches. Adaptable owns the props it passes to Infinite Table — overriding them can break views, sorting, grouping or selection. Prefer adaptableApi (gridApi, dataSourceApi, viewApi, …) whenever it covers your case.

#Custom InfiniteTable and DataSource components

Pass your own components through the components input of <adaptable-provider>:

Custom InfiniteTable rendering
import { Component, computed, input } from '@angular/core';
import {
  AdaptableEngineDataSource,
  AdaptableEngineTable,
  AdaptableProvider,
  AdaptableUI,
  type AdaptableProps,
} from '@adaptabletools/datagrid-angular';
import type {
  DataSourceProps,
  InfiniteTableProps,
} from '@adaptabletools/datagrid-angular/infinite';

@Component({
  selector: 'my-infinite-table',
  imports: [AdaptableEngineTable],
  template: `<ng-container [adaptableEngineTable]="tableProps()" />`,
})
class MyInfiniteTable {
  // the props Adaptable computed for the engine table
  readonly props = input.required<InfiniteTableProps<Developer>>();
  protected readonly tableProps = computed(
    (): InfiniteTableProps<Developer> => ({ ...this.props(), ...yourExtraProps }),
  );
}

@Component({
  selector: 'my-data-source',
  imports: [AdaptableEngineDataSource],
  template: `<ng-container [adaptableEngineDataSource]="props()" />`,
})
class MyDataSource {
  readonly props = input.required<DataSourceProps<any>>();
}

const components: AdaptableProps<Developer>['components'] = {
  InfiniteTable: MyInfiniteTable,
  DataSource: MyDataSource,
};

@Component({
  selector: 'app-root',
  imports: [AdaptableProvider, AdaptableUI],
  template: `
    <adaptable-provider [components]="components"
      adaptableId="app"
      primaryKey="id"
      [data]="data"
    >
      <adaptable-ui />
    </adaptable-provider>
  `,
})
export class App {
  protected readonly data = data;
  protected readonly components = components;
}

Each component receives the props Adaptable computed for it — columns, column order and sizing, sort info, group by, selection and their change handlers — and must render the real InfiniteTable / DataSource with them.

Each of them is a wrapper: a component with a props input, which gets everything Adaptable computed as one object, with the React names of the props (columns, onColumnOrderChange, …). Its template renders the engine component with the props it wants, changed or not: <ng-container [adaptableEngineTable]="…" /> for the table, <ng-container [adaptableEngineDataSource]="…" /> for the data source (AdaptableEngineTable and AdaptableEngineDataSource, exported by the package). An <ng-template let-props> works as a wrapper too. The element of a wrapper component is laid out with display: contents, so the engine component takes its place.

When you intercept a callback Adaptable already provides, call the original too, or Adaptable's state stops following the grid:

protected readonly tableProps = computed((): InfiniteTableProps<Developer> => {
  const props = this.props();
  return {
    ...props,
    onColumnOrderChange: (columnOrder) => {
      console.log('columnOrder', columnOrder);
      // keep Adaptable in sync
      props.onColumnOrderChange?.(columnOrder);
    },
  };
});
Note

Pass the component classes, and change components.InfiniteTable / components.DataSource only to swap in another component: a different class (or template) creates the grid again.

Your custom components are rendered inside the provider, so they can call the inject functions — for example injectAdaptableState or injectAdaptableApi.

The same components prop also accepts Infinite Table's own component overrides (they are passed through to InfiniteTable), and Adaptable's replaceable parts such as the settings panel view editors — see Replacing built-in parts.

#
Intercepting InfiniteTable and DataSource callbacks

The custom InfiniteTable logs column order changes and the custom DataSource logs data loads, while both still call the handlers Adaptable passed in.

Drag a column header to a new position and watch the log above the grid.

open
loading demo…

#The raw Infinite Table APIs

The @adaptabletools/datagrid-angular/infinite entry point gives you engine access:

import { injectAdaptableApi } from '@adaptabletools/datagrid-angular';
import { getInfiniteTableApi } from '@adaptabletools/datagrid-angular/infinite';

@Component({
  selector: 'scroll-to-top',
  template: `<button (click)="scrollToTop()">Scroll to top</button>`,
})
export class ScrollToTop {
  // a signal of the api: call it in a template, a handler or an effect
  private readonly adaptableApi = injectAdaptableApi();

  protected scrollToTop() {
    getInfiniteTableApi(this.adaptableApi()).scrollTop = 0;
  }
}
  • getInfiniteTableApi(adaptableApi) — the Infinite Table API.
  • getInfiniteDataSourceApi(adaptableApi) — the Infinite DataSourceApi.
  • InfiniteTable, DataSource and debug re-exported from @infinite-table/infinite-angular, plus the InfiniteTableApi, InfiniteTableProps, DataSourceApi, DataSourceProps and InfiniteTableRowInfo types.

The same APIs are available as adaptableApi.getInfiniteTableApi() and adaptableApi.getInfiniteDataSourceApi(). They throw until the grid is rendered — call them from event handlers or after the (ready) output.