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
#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.
#
contextMenuAdaptableBaseView['contextMenu']resolves tostring | undefined#
dataSourceAdaptableBaseView['dataSource']resolves toAdaptableDataSourceConfig | undefined#
dateFormatAdaptableBaseView['dateFormat']resolves tostring | ((date: Date) => string) | undefined#
keyboardNavigationAdaptableBaseView['keyboardNavigation']resolves toInfiniteTablePropKeyboardNavigation | undefined#
selectionModeAdaptableBaseSelection['mode']resolves toAdaptableSelectionMode | undefined#
singleColumnSortAdaptableBaseView['singleColumnSort']resolves toboolean | undefined
#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.
import {
Adaptable,
type AdaptableUserState,
} from '@adaptabletools/datagrid-react';
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',
},
],
},
];
export default function App() {
return (
<Adaptable.Provider
adaptableId="app"
primaryKey="id"
data={data}
defaultState={{
dashboard: {
top: {
widgets: [{ id: 'views', type: 'view' }],
},
},
globalEntities: {
availableColumns,
},
view: {
currentViewId: 'pivot',
views,
},
}}
>
<Adaptable.Workspace />
</Adaptable.Provider>
);
}