Adaptable

AdaptableViewState

Declared in src/modules/view/State.ts

The state of the Views module, under state.view: the views of the grid and which one is active.

A view is everything the grid shows at a given time - which columns and in what order, the sorting, row grouping, pivoting, aggregations and filters. One view is active at a time: users switch views in the view picker, and code with api.viewApi.setActiveView(). Changes made to a view at runtime are saved in the state, so they are persisted.

Views have other associated objects: styled cells, alerts, grid filter, column filters and more, so they are the heart of the grid.

Each view is a table view or a pivot view - see AdaptableViewState.views. Views pick their columns from state.globalEntities.availableColumns, and viewDefaults sets fallbacks for the settings a view doesn't set itself.

view: {
  currentViewId: 'all',
  views: [
    {
      id: 'all',
      label: 'All developers',
      styledCells: ['backend-highlight'],
    },
    {
      id: 'by-language',
      label: 'By language',
      groupColumns: {
        'language-group': { groupBy: 'preferredLanguage' },
      },
    },
  ],
},

#Properties

3 props

#currentViewIdrequiredstring

Denotes which of the views is currently active. You need to have an active view to render the grid.

#viewDefaults{ … }

Default values for all views. They only override properties that are not defined in the view itself.

#viewsrequiredXOR<AdaptableTableView, AdaptablePivotView>[]

The list of views available in the application.

A view is either a AdaptableTableView (see Table View docs) or a AdaptablePivotView (see Pivot View docs).

A pivot view is defined by the AdaptablePivotView.pivotColumns property (even if just an empty array is provided). Without it, the view will be a table view.

#
2 views - pivot and table
<script setup lang="ts">
import { Adaptable, type AdaptableUserState } from '@adaptabletools/datagrid-vue';
import { data } from '';
import { availableColumns } from '';

const views: AdaptableUserState['view']['views'] = [
  {
    id: 'table view',
    label: 'Table View',
    columnOrder: ['firstName', 'country', 'salary'],
  },
  {
    id: 'pivot',
    label: 'Pivot View',
    pivotColumns: [{ columnId: 'country' }],
    pivotGroupColumns: [{ id: 'country', groupBy: ['preferredLanguage'] }],
    pivotAggregationColumns: [
      {
        columnId: 'salary',
        aggregation: 'avg',
      },
    ],
  },
];

const defaultState: AdaptableUserState = {
  dashboard: {
    top: {
      widgets: [{ id: 'views', type: 'view' }],
    },
  },
  globalEntities: {
    availableColumns,
  },

  view: {
    currentViewId: 'pivot',
    views,
  },
};
</script>

<template>
  <Adaptable.Provider adaptableId="app" primaryKey="id" :data="data" :defaultState="defaultState">
    <Adaptable.Workspace />
  </Adaptable.Provider>
</template>

#Used by