Transposing Grid Data

View as Markdown

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 columnsToTranspose and rowsToTranspose properties to limit scope when needed

It is a simple 2-step process to create a Transposed View:

  1. Open the transposed view from code with showTransposedView on the Grid API section of Adaptable API
  2. Pass a TransposeConfig object

The main options fit together as follows:

OptionRole
transposedColumnIdColumn whose values become the headers of the transposed grid (defaults to Primary Key if omitted)
columnsToTransposeWhich source columns appear as rows in the transposed view (default: all columns)
rowsToTransposeWhich source rows supply the columns of the transposed view—All, VisibleOnly, or an AdapTableQL Boolean Expression (default: all rows)
transposedViewContainerWhere 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: TransposeConfig
void
Displays a Transposed View of the grid
Transposing the Grid
Fork
  • This demo shows how to transpose the Grid
  • Clicking the Transpose Grid Button will open a new view that transposes the current grid
Loading demo…

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

Transposing: Configuring Columns
Fork
  • In this example we have set an implementation for the columnsToTranspose property to limit which Columns are transposed
  • We provide a function which returns all numeric columns plus the Language column
Loading demo…

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
Transposing: Configuring Rows
Fork
  • In this example we have set an implementation for the rowsToTranspose property
  • We provide an AdapTableQL Expression: [github_stars] > 60000 AND [language] != "HTML"
Loading demo…

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

Transposing the Grid
Fork
  • 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
Loading demo…

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 showTransposedView again with the same config when the user returns