Hiding Columns
Summary
- AdapTable allows Columns to be defined as Hidden, by setting a type of
hiddenColumnin ColDefs - Hidden Columns are never visible in the Grid (or the AdapTable UI) but can be used in Expressions
Columns can be hidden in AdapTable so that they are never displayed in the UI.
This is especially useful if you are using a primary key column which you do not want users to see or edit.
Note
- A hidden Column will be still be listed in the Columns section of the Expression Editor and in the Query Builder
- This allows it to form part of an Expression (e.g. to be used in Calculated Columns or the Grid Filter)
This is done setting (or adding) hiddenColumn to the type property in the AG Grid ColdDef definition.
Hint
- Alternatively you can use the
AdaptableColumnType.HiddenColumnconstant - See the Guide to Providing Column Types for more information of setting column types
// Add 2 hidden columns
export const columnDefs: ColDef<WebFramework>[] = [
{
field: 'id',
cellDataType: 'number'
type: 'hiddenColumn'
},
{
field: 'map',
cellDataType: 'text'
type: AdaptableColumnType.HiddenColumn
},
]Caution
- AG Grid offers a similar ColDef property named
hidewhich if set to true will hide the Column - AdapTable ignores this property and sets visibility based purely on Layout properties and the
hiddenColumntype
Hiding a Column in AdapTable UI
- In this example we "hide" the
Github WatchersandGithub StarsColumns by setting their ColDeftypeproperty to HiddenColumn - As a result they are not visible in the Grid, nor in the
ColumnsTool Panel and nor the Layout Wizard - However they are stil available for use in Expression Editor and Query Builder
Try It Out
- Open Columns Tool Panel and note the
Github WatchersandGithub StarsColumns are not listed (but the Calculated ColumnGithub Totalis listed) - Edit the Grid Filter, or the
Github TotalCalculated Column, and noteGithub Watchers&Github StarsColumns are referenced in the Expression and available in Expression Editor and Query Builder - Note also that we set the
Namecolumn with hide in ColDefs but that gets ignored by AdapTable and the column is displayed (as its in the Layout)
Breaking Change
- Prior to AdapTable 21 fully hidden columns could only be achieved by a combination of 4
ColDefproperties - These needed explicitly setting to true:
hide,lockVisible,suppressColumnsToolPanel,suppressFiltersToolPanel