Transposing Grid Data
Summary
- Transposition lets users see grid data with rows and columns switched, in a similar way to Excel’s Transpose
- AdapTable opens a separate transposed view (but does not swap main grid’s row/column model in place)
- Configuration options include:
- which column labels the transposed axes
- which columns and rows take part
- where transposed view is rendered
Transposition is similar to Excel in outcome: metrics that were columns can now be read down the grid
However it is delivered as a dedicated transposed view not on underlying grid.
Note
The primary reason is that transposition is not possible in AG Grid due to its architectural constraints
Transposition is particularly userful when comparing many column values for a relatively small set of rows.
It allows you to scan a wide table in a “one row per metric” layout.
Caution
- Transposing all columns or many rows produces a very wide or tall transposed view
- Use the
columnsToTransposeandrowsToTransposeproperties to limit scope when needed
It is a simple 2-step process to create a Transposed View:
- Open the transposed view from code with
showTransposedViewon the Grid API section of Adaptable API - Pass a
TransposeConfigobject
The main options fit together as follows:
| Option | Role |
|---|---|
transposedColumnId | Column whose values become the headers of the transposed grid (defaults to Primary Key if omitted) |
columnsToTranspose | Which source columns appear as rows in the transposed view (default: all columns) |
rowsToTranspose | Which source rows supply the columns of the transposed view—All, VisibleOnly, or an AdapTableQL Boolean Expression (default: all rows) |
transposedViewContainer | Where the transposed grid is mounted (default: popup; set this to use a custom region — see Rendering Transposed View) |
Caution
transposedViewContainer is configured in Container Options (and not TransposeConfig like other properties)
showTransposedView
transposeConfig: TransposeConfigvoid- This demo shows how to transpose the Grid
- Clicking the
Transpose GridButton will open a new view that transposes the current grid
Selecting Columns
By default all Grid Columns are transposed.
However, if this is not the required behaviour, AdapTable allows developers to specify which Columns should be transposed, when calling the showTransposedView function.
This is done via the columnsToTranspose property in the TransposeConfig object sent to the function.
Hint
Developers can either provide a list of ColumnIds directly, or a function that returns a list of ColumnIds
- In this example we have set an implementation for the
columnsToTransposeproperty to limit which Columns are transposed - We provide a function which returns all numeric columns plus the
Languagecolumn
Selecting Rows
By default all Grid Rows are also transposed.
Again, if this is not the required behaviour, AdapTable allows developers to specify the Rows to transpose.
This is done via the rowsToTranspose property in the TransposeConfig object sent to the function.
Developers can provide 3 options for this property:
All- transposes all rows in the DataSet (default value if nothing provided)VisibleOnly- transposes only rows currently in the Grid (including in Groups)- AdapTableQL Boolean Expression - only rows that evaluate as true in the provided Expression are transposed
- In this example we have set an implementation for the
rowsToTransposeproperty - We provide an AdapTableQL Expression:
[github_stars] > 60000 AND [language] != "HTML"
Rendering Transposed View
By default the Transposed Grid will be displayed in a popup above AG Grid.
This, too, can be changed in AdapTable if need be.
The solution is to provide a property for the transposedViewContainer property in Container Options.
Find Out More
Read the Tutorial on providing Container Options for full details on how to specify Custom Divs in AdapTable
- This demo displays the Transposed View on the right-hand side of the viewport (50%)
- The main grid shrinks to 50% when the transposed view is open
- When the transposed view is closed, the main grid takes 100% of the width
- A header with a close button (✕) allows you to hide the transposed view
FAQ
Can we save the transposed view?
No. Opening or closing the transposed view and the TransposeConfig passed to showTransposedView are not part of persisted Adaptable State (for example Layout).
Hint
- You can still persist your own UI preference in application state however
- And you can then call
showTransposedViewagain with the same config when the user returns