#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
InfiniteTableandDataSourcecomponents Adaptable renders, to add props or intercept callbacks. - Get the raw Infinite Table APIs.
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 />:
<script setup lang="ts">
import { h } from 'vue';
import { Adaptable, type AdaptableProps } from '@adaptabletools/datagrid-vue';
import { InfiniteTable, DataSource } from '@infinite-table/infinite-vue';
import type { Developer } from '../getting-started/basic.data';
declare const yourExtraProps: Record<string, unknown>;
declare const otherProps: AdaptableProps<Developer>;
declare const data: Developer[];
const components: AdaptableProps<Developer>['components'] = {
InfiniteTable: (props) => {
return h(InfiniteTable, { ...props, ...yourExtraProps });
},
// the grid is the default slot of the DataSource: pass the slots on
DataSource: (props, { slots }) => {
return h(DataSource, { ...props }, slots);
},
};
</script>
<template>
<Adaptable.Provider v-bind="otherProps" :data="data" :components="components">
<Adaptable.UI />
</Adaptable.Provider>
</template>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 function, as above, or a component:
- A function is called with all the props, and with the context (
slots,attrs) as its second argument, and what it returns is rendered. TheDataSourcehas to pass the slots on: the grid is its default slot. - A component (a
.vuefile,defineComponent) is what calls a composable. The props Adaptable computed are itsattrs: it declares none of them, setsinheritAttrs: falseand passes them on, as any component that wraps another does in Vue.
<script setup lang="ts">
import { useAttrs } from 'vue';
import { InfiniteTable } from '@infinite-table/infinite-vue';
import { useAdaptableState } from '@adaptabletools/datagrid-vue';
// the props Adaptable computed are the attrs of this component: it declares
// none of them, and passes them on itself
defineOptions({ inheritAttrs: false });
const attrs = useAttrs();
const viewId = useAdaptableState((state) => state.view.currentViewId);
</script>
<template>
<InfiniteTable v-bind="attrs" :loadingText="`Loading the ${viewId} view…`" />
</template>When you intercept a callback Adaptable already provides, call the original too, or Adaptable's state stops following the grid:
InfiniteTable: (props) => {
const onColumnOrderChange: typeof props.onColumnOrderChange = (columnOrder) => {
console.log('columnOrder', columnOrder);
// keep Adaptable in sync
props.onColumnOrderChange?.(columnOrder);
};
return h(InfiniteTable, { ...props, onColumnOrderChange });
},Create the components object once: in <script setup> or outside the
component, not in the template or in a computed. A new InfiniteTable /
DataSource function or component unmounts and remounts the grid.
Your custom components are rendered inside the provider, so a component can call the composables in its setup — 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.
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.
#The raw Infinite Table APIs
The @adaptabletools/datagrid-vue/infinite entry point gives you engine
access:
<script setup lang="ts">
import { useAdaptableApi } from '@adaptabletools/datagrid-vue';
import { getInfiniteTableApi } from '@adaptabletools/datagrid-vue/infinite';
const adaptableApi = useAdaptableApi();
const scrollToTop = () => {
getInfiniteTableApi(adaptableApi).scrollTop = 0;
};
</script>
<template>
<button @click="scrollToTop">Scroll to top</button>
</template>getInfiniteTableApi(adaptableApi)— the Infinite Table API.getInfiniteDataSourceApi(adaptableApi)— the InfiniteDataSourceApi.InfiniteTable,DataSourceanddebugre-exported from@infinite-table/infinite-vue, plus theInfiniteTableApi,InfiniteTableProps,DataSourceApi,DataSourcePropsandInfiniteTableRowInfotypes.
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.