Configuring Column Header
Summary
- AdapTable users are able to change the Header / Caption of a Column in AG Grid in 2 ways:
- Changes configured in a particular Layout
- Changes set through Column Options
By default, AdapTable will show as the header (or caption) of the Column (ie. the text that appears in the Header Bar) the default value provided in AG Grid's ColumnDefs.
However this can be changed in AdapTable in 2 ways (using this order of evaluation):
- on a per-Layout basis using the
ColumnHeadersproperty - via the
columnHeaderfunction in Column Options
Per Layout
The highest level of priority are changes made to a given Layout using the ColumnHeaders property.
Note
- This enables the same Column to have different Headers / Captions in 2 Layouts
- It also allows the Column's Header to be set at run-time via the AdapTable UI
A custom Column Header can be set in a Layout (using the ColumnHeaders property) in many ways:
- In Layout Initial State (i.e. by developers at design-time)
- Using the
Change Captionmenu option in each Column Menu - In the
Columnssection of the Layout Wizard (via the dropdown which opens an expanded section) - Programatically using the
setColumnCaptionfunction in Layout API
Hint
- AG Grid makes it easy to wrap Column Headers - useful when the header text is wider than the cell text
- The
wrapHeaderText&autoHeaderHeightprops in Column Defs, when set to true, creates the necessary effect
- This demo shows how to change the Column Header on a per-Layout basis
- In the Initial State for the
StandardLayout we change 'Name' toJavaScript Frameworkand 'Gihub Stars' toFans - Note: we set
wrapHeaderTextandautoHeaderHeightto true in Column Def's to create a better visual effect - We provide a Dashboard button to allow the Header for "Updated" to be set via the Layout API
- Switch between Layouts and note that the
GroupedLayout contains the original Column Headers - Change a Column Header using the
Change HeaderMenu Item in the Column Menu - Change another Column's Header by using the Layout Editor's Wizard
Using a Function
The columnHeader function in Column Options provides a more configurable way to change Column Headers.
Caution
Changes made to Column Headers in a Layout (either in Layout Initial State or in the UI) will take precedence
The function allows headers to be programatically set for each Column (or type of Column).
The function's context supports many different categories of column, including dynamically created ones.
columnHeader
string- This demo shows how to change the Column Header programatically. We change the Header for various types of columns (visible via different Layouts):
- For
tableColumnwe change 'Name' toJS Framework(seeTable Layout) - For
autoGroupColumnwe change the header to "My Row Group" (seeRow Grouped Layout) - For
tableColumnGroupwe change the header to "My Column Group" (seeColumn Group Layout) - For
pivotResultColumnwe add prefix of "Agg" to header (seePivot Layout) - For
pivotColumnGroupwe add prefix of "PC" to header (also seePivot Layout)
- For
- Switch between Layouts and see the different Headers
- Change the Language / JavasScript Framework Column Header by using the Layout Editor's Wizard and not it takes precedence