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):

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 Caption menu option in each Column Menu
  • In the Columns section of the Layout Wizard (via the dropdown which opens an expanded section)
  • Programatically using the setColumnCaption function 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 & autoHeaderHeight props in Column Defs, when set to true, creates the necessary effect
Custom Column Headers Layout
Fork
  • This demo shows how to change the Column Header on a per-Layout basis
  • In the Initial State for the Standard Layout we change 'Name' to JavaScript Framework and 'Gihub Stars' to Fans
  • Note: we set wrapHeaderText and autoHeaderHeight to 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
Try It Out
  • Switch between Layouts and note that the Grouped Layout contains the original Column Headers
  • Change a Column Header using the Change Header Menu 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
Provide Custom Column Headers
Custom Column Headers Function
Fork
  • This demo shows how to change the Column Header programatically. We change the Header for various types of columns (visible via different Layouts):
    • For tableColumn we change 'Name' to JS Framework (see Table Layout)
    • For autoGroupColumn we change the header to "My Row Group" (see Row Grouped Layout)
    • For tableColumnGroup we change the header to "My Column Group" (see Column Group Layout)
    • For pivotResultColumn we add prefix of "Agg" to header (see Pivot Layout)
    • For pivotColumnGroup we add prefix of "PC" to header (also see Pivot Layout)
Try It Out
  • 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