# Sizing Pivot Layouts

Canonical page: https://www.adaptabletools.com/docs/handbook-layouts-pivot-sizing

- The widths of Pivot Result Columns can be saved in a Pivot Layout

[Layouts](https://www.adaptabletools.com/docs/handbook-layouts/index.md) · [Pivot Layouts](https://www.adaptabletools.com/docs/handbook-layouts-pivot/index.md) · [All Pivot Layout Topics](https://www.adaptabletools.com/docs/handbook-layouts-pivot/index.md#pivot-layout-topics).
Table layout sizing — [Table Layouts — Column Sizing](https://www.adaptabletools.com/docs/handbook-layouts-table-column-sizing/index.md).

Layout Column Sizing in Pivot Layouts is configured using the `ColumnSizing` property.

This property - also used for Table Layouts - allows you set the width (or flex) for each Column in the Layout.

Additionally you can set the Minumum Width, Maximum Width and Resizability of each Column.

See [Table Layout Column Sizing](https://www.adaptabletools.com/docs/handbook-layouts-table-column-sizing/index.md) for an in-depth discussion of the objects used

## Pivot Aggregation Columns

Pivot Aggregation Columns can easily be sized, and given either a Width or a Flex.

**Example: Pivot Aggregation Columns: Widths**

Setting & Saving Column Widths of Pivot Aggregation Columns

 

- In this example we provide bespoke Column Widths of 350px for 2 Pivot Aggregation Columns in the Layout Definition - `Github Stars` and `Github Watchers`

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Pivot Aggregation Columns: Saving Widths',
  initialState: {
    Dashboard: {
      Tabs: [{Name: 'Demo', Toolbars: ['Layout']}],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Pivot Layout',
      Layouts: [
        {
          Name: 'Pivot Layout',
          PivotColumns: [],
          PivotGroupedColumns: ['language'],
          SuppressAggFuncInHeader: true,
          PivotAggregationColumns: [
            {
              ColumnId: 'github_watchers',
              AggFunc: 'sum',
            },
            {
              ColumnId: 'github_stars',
              AggFunc: 'sum',
            },
          ],
          ColumnSizing: {
            github_watchers: {Width: 350},
            github_stars: {Width: 350},
          },
        },
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'popularity',
            'license',
            'open_issues_count',
            'created_at',
            'has_wiki',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## Pivot Result Columns

AdapTable also allows you to define - and save - the widths of [Pivot Result Columns](https://www.adaptabletools.com/docs/handbook-layouts-pivot-result-columns/index.md).

AG Grid dynamically generates Pivot Result Columns for each unique permutation of Pivot Column value and Aggregation Column

Saving Pivot Result Columns Widths is also done using the Layout's `ColumnSizing` property. 

**Example: Pivot Result Columns: Widths**

Setting & Saving Column Widths of Pivot Result Columns

 

- In this example we provide bespoke Column Widths for 2 Pivot Result Columns in the Layout Definition (both using AG Grid's autogenerated `ColumnId`)
- `pivot_language_HTML_github_watchers` and `pivot_language_JavaScript_github_stars` are both given custom widths of 350px
- Note: Although we have set the widths in the Layout, it is far more common for the User to set them in the UI (and for AdapTable to persist those changes)

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Pivot Result Columns: Saving Widths',
  initialState: {
    Dashboard: {
      Tabs: [{Name: 'Demo', Toolbars: ['Layout']}],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Pivot Layout',
      Layouts: [
        {
          Name: 'Pivot Layout',
          PivotColumns: ['language'],
          PivotGroupedColumns: ['license'],
          SuppressAggFuncInHeader: true,
          PivotAggregationColumns: [
            {
              ColumnId: 'github_watchers',
              AggFunc: 'sum',
            },
            {
              ColumnId: 'github_stars',
              AggFunc: 'sum',
            },
          ],
          ColumnSizing: {
            pivot_language_HTML_github_watchers: {Width: 350},
            pivot_language_JavaScript_github_stars: {Width: 350},
          },
        },
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'popularity',
            'license',
            'open_issues_count',
            'created_at',
            'has_wiki',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```
