Column.md

November 13, 2019 · View on GitHub

Column

Describes the header and cell contents of a table column.

Prop Types

PropertyTypeRequired?Description
cellDataGetterFunctionCallback responsible for returning a cell's data, given its dataKey. Learn more
cellRendererFunctionCallback responsible for rendering a cell's contents. Learn more
classNameStringCSS class to apply to rendered cell container
columnDataObjectAdditional data passed to this column's cellDataGetter. Use this object to relay action-creators or relational data.
dataKeyanyUniquely identifies the row-data attribute corresponding to this cell (eg this might be "name" in an array of user objects).
defaultSortDirectionSortDirectionDefault sort order when clicked for the first time. Valid options include "ASC" and "DESC". Defaults to "ASC"
disableSortBooleanIf sort is enabled for the table at large, disable it for this column
flexGrowNumberFlex grow style; defaults to 0
flexShrinkNumberFlex shrink style; defaults to 1
headerClassNameStringCSS class to apply to this column's header
headerRendererFunctionOptional callback responsible for rendering a column's header column. Learn more
headerStyleObjectOptional inline style to apply to this column's header
idStringOptional id to set on the column header; used for aria-describedby
labelNodeHeader label for this column
maxWidthNumberMaximum width of column; this property will only be used if :flexGrow is greater than 0
minWidthNumberMinimum width of column
styleObjectOptional inline style to apply to rendered cell container
widthNumberFlex basis (width) for this column; This value can grow or shrink based on flexGrow and flexShrink properties

cellDataGetter

Callback responsible for returning a cell's data, given its dataKey. It should implement the following signature:

function ({
  columnData: any,
  dataKey: string,
  rowData: any
}): any

A default cellDataGetter is provided that simply returns the attribute as a String. This function expects to operate on either a vanilla Object or a Map-like object with a get method. You should override this default method if your data is calculated or requires any custom processing.

cellRenderer

Callback responsible for rendering a cell's contents. It should implement the following signature:

function ({
  cellData: any,
  columnData: any,
  columnIndex: number,
  dataKey: string,
  isScrolling: boolean,
  rowData: any,
  rowIndex: number
}): node

A default cellRenderer is provided that displays an attribute as a simple string You should override this default method if your data is some other type of object or requires custom formatting.

headerRenderer

Callback responsible for rendering a cell's header column. It should implement the following signature:

function ({
  columnData: any,
  dataKey: string,
  disableSort: boolean,
  label: any,
  sortBy: string,
  sortDirection: SortDirection
}): element

A default headerRenderer is provided that displays the column label along with a sort indicator if the column is sort-enabled and active. You should override this default method if you want to customize the appearance of table columns.