Adaptable

#Hooks

Adaptable exposes its state and API to your own Vue components through composables. Each one has the name of the React hook it matches, so this section keeps the name "hooks".

Call a composable in <script setup> (or in setup()) of any component rendered inside <Adaptable.Provider> — next to <Adaptable.UI />, inside a custom column header, in a toolbar, or in a custom InfiniteTable component.

CurrentViewLabel.vue
<script setup lang="ts">
import { useCurrentViewState } from '@adaptabletools/datagrid-vue';

// a ref of the current view
const view = useCurrentViewState();
</script>

<template>
  <div>Current view: {{ view?.label ?? view?.id }}</div>
</template>
Rendered inside the provider
<Adaptable.Provider v-bind="props">
  <CurrentViewLabel />
  <Adaptable.UI />
</Adaptable.Provider>

All composables are named exports of @adaptabletools/datagrid-vue.

#What a composable returns

  • useAdaptableApi(), useAdaptableActions() and useAdaptableId() return the value itself, not a ref.
  • useAdaptableStateSubscribe() returns nothing.
  • useAdaptableState(), useCurrentViewState(), useCellSelection() and useRowSelection() return a read-only shallow ref (Readonly<ShallowRef<T>>) of the value described below.
  • useVisibleColumns() and every other composable on this page return a computed ref (ComputedRef<T>) of what is described below — for most of them one object with the values and the functions: const views = useViews(), then views.value.currentView and views.value.setActiveView(viewId).

Read .value in the script; a template unwraps a ref held in a top-level variable of <script setup>. Read it where it is used — in the template, a computed, a watch or an event handler: what is taken out of .value directly in setup is the value of that moment and does not follow the state. The state is not made deeply reactive: a ref gets a new value when the state it reads changes.

#State and API

#Current view and selection

  • useCurrentViewState() — returns the state of the active view (table or pivot), or undefined.
  • useVisibleColumns() — returns the visible columns of the current table view, in view order; an empty array for pivot views.
  • useCellSelection() — returns { columnIds, positions } for the selected cells, or null when nothing is selected.
  • useRowSelection<T>() — returns the selected rows as row info objects, or null when the view has no row selection.
  • useViewSelection() — the effective selection mode and keyboardNavigation of the current view, the columns that can show the selection checkbox, plus setMode, setKeyboardNavigation ('auto' follows the mode), setSelectionColumn and multiSelectTarget / setMultiSelectTarget. See Selection and Keyboard navigation.

#Views and columns

These composables operate on the current view. They power the built-in settings panel editors, so you can use them to build your own.

  • useViews() — views, currentViewId, currentView, plus setActiveView, createTableView, createPivotView, cloneView, deleteView and renameView.
  • useViewColumns() — the columns of the current table view (including hidden and group columns), availableColumns, columnsNotInView, plus setColumnOrder, setColumnVisible, addColumn, removeColumn, setColumnsInView, setColumnModel and patchColumn.
  • useColumnSizing() — the view columns plus setColumnSizing(columnId, { width, flex, minWidth, maxWidth }); pass null to clear a field.
  • useColumnPinning() — the view columns plus setColumnPinned(columnId, pinned).
  • useColumnLabels() — the view columns (each with its label and defaultLabel) plus setColumnLabel(columnId, label); an empty label or null restores the default.
  • useColumnProperties() — the view columns (each with its definition and the view's override) plus getProperty(columnId, key) ({ value, inherited, overridden }), setProperty(columnId, key, value) (null or the inherited value removes the override), isColumnOverridden(columnId) and resetColumn(columnId). It powers the column inspector on the Columns settings page. See Editing columns in the UI.
  • useColumnSorting() — sorting (in priority order), sortableColumns, singleColumnSort, plus setSorting(sorting) and setSort(columnId, dir | null).
  • useColumnGrouping() — groupColumns, groupedColumnIds, groupableColumns, the render strategy ('single-column' | 'multiple-columns'), plus addGroupByColumn, removeGroupByColumn, setGrouping, clearGrouping, setStrategy and setGroupColumnField. Table views only.
  • useColumnAggregations() — aggregatableColumns, aggregations, plus setAggregation(columnId, aggregation), setAggregations(record) and getAggregationOptions(column). Works for table and pivot views.
  • useAggregationTypes() — customAggregationTypes (the AdaptableQL aggregation types of the current view defined in state, each with allViews), plus saveAggregationType(id, config, { allViews }), deleteAggregationType(id, { allViews }) and getUniqueId(label). See Editing aggregations in the UI.
  • useCalculatedColumns() — calculatedColumns, plus createCalculatedColumn, updateCalculatedColumn, deleteCalculatedColumn, addToCurrentView, removeFromCurrentView and getDataTypeFromExpression. See Calculated Columns.
  • useGridFilter() — gridFilter (the AQL expression, '' when none), isPaused, plus setGridFilter, clearGridFilter, setPaused and isValidGridFilter. See Grid Filter.
  • useColumnFilters() — columnFilters (expression, column, paused state, error), plus addColumnFilter, setColumnFilter, removeColumnFilter, clearColumnFilters, setPaused and setAllPaused. See Column Filters.
  • useNamedQueries() — namedQueries, plus createNamedQuery, updateNamedQuery, deleteNamedQuery, getNamedQueryByName and getReference(name) (returns QUERY("name")).
  • useQuickSearchConfig() — the quick search config and updateConfig(patch). See Quick Search.

For custom column filter editors, useColumnFilterEditor() and useColumnFilterValues(() => options) give you the editor context and the pickable values of a column. useColumnFilterValues takes a function that returns the options, so that the options can change.

#Pivoting

  • usePivotColumns() — pivotColumns, pivotableColumns, showTotalColumns, plus setPivotColumns, addPivotColumn, removePivotColumn and setShowTotalColumns. See Pivot Views.
  • usePivotGrouping() — the same shape as useColumnGrouping, for the row groups of the current pivot view.

#Styling, alerts and export

  • useStyledCells() — styledCells, currentViewStyledCellIds, plus createStyledCell, updateStyledCell, deleteStyledCell, addToCurrentView, removeFromCurrentView and setCurrentViewStyledCells. See Styled Cells.
  • useFlashingCells() — the same shape for flashing cells (flashingCells, createFlashingCell, …). See Flashing Cells.
  • useAlerts() — alerts, customActions, plus createAlert, updateAlert and deleteAlert. See Alerts.
  • useCellNotes() — threads, allThreads, unreadCount, unreadMentions, getThreads(filter), plus the open popover target. Mutations go through adaptableApi.cellNoteApi. See Cell Notes.
  • useReports() — reports, destinations, plus createReport, updateReport, deleteReport and runReport(reportId, destination).
  • useTheme() — themes, currentThemeId, accentColors, currentAccentColor, plus setTheme and setAccentColor. See Theming.