Adaptable

#Infinite Table Integration

Adaptable renders its grid with Infinite Table: <Adaptable.UI.DataGrid /> (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 prop of <Adaptable.Provider />:

Custom InfiniteTable rendering
import { Adaptable, AdaptableProps } from '@adaptabletools/datagrid-react';
import { InfiniteTable, DataSource } from '@infinite-table/infinite-react';

const components: AdaptableProps<Developer>['components'] = {
  InfiniteTable: (props) => {
    return <InfiniteTable {...props} {...yourExtraProps} />;
  },
  DataSource: (props) => {
    return <DataSource {...props} />;
  },
};

function App() {
  return (
    <Adaptable.Provider {...otherProps} data={data} components={components}>
      <Adaptable.UI />
    </Adaptable.Provider>
  );
}

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.

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

InfiniteTable: (props) => (
  <InfiniteTable
    {...props}
    onColumnOrderChange={(columnOrder) => {
      console.log('columnOrder', columnOrder);
      // keep Adaptable in sync
      props.onColumnOrderChange?.(columnOrder);
    }}
  />
),
Note

Declare the components object outside your React components (or memoize it). A new InfiniteTable / DataSource component on every render unmounts and remounts the grid.

Your custom components are rendered inside the provider, so they can use the hooks — for example useAdaptableState or useAdaptableApi.

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-react/infinite entry point gives you engine access:

import { useAdaptableApi } from '@adaptabletools/datagrid-react';
import { getInfiniteTableApi } from '@adaptabletools/datagrid-react/infinite';

function ScrollToTop() {
  const adaptableApi = useAdaptableApi();
  const scrollToTop = () => {
    getInfiniteTableApi(adaptableApi).scrollTop = 0;
  };
  return <button onClick={scrollToTop}>Scroll to top</button>;
}
  • getInfiniteTableApi(adaptableApi) — the Infinite Table API.
  • getInfiniteDataSourceApi(adaptableApi) — the Infinite DataSourceApi.
  • InfiniteTable, DataSource and debug re-exported from @infinite-table/infinite-react, 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 mounted — call them from event handlers or after onReady.