这些是所有表头的核心选项和 API 属性。其他表格功能可能还有更多选项和 API 属性。
所有表头对象都具有以下属性:
id
id: string
表头的唯一标识符。
index
id: number
表头在表头组中的索引。
depth
id: number
表头的深度,基于零索引。
column
column: Column<TData>
表头关联的Column对象。
headerGroup
headerGroup: HeaderGroup<TData>
表头关联的HeaderGroup对象。
subHeaders
type subHeaders = Header<TData>[]
表头的层次子/子表头。如果表头关联的列是叶子列,则为空。
colSpan
colSpan: number
表头的列跨度。
rowSpan
rowSpan: number
表头的行跨度。
getLeafHeaders
type getLeafHeaders = () => Header<TData>[]
返回在此表头下层次嵌套的叶子表头。
isPlaceholder
isPlaceholder: boolean
一个布尔值,表示表头是否为占位符表头。
placeholderId
placeholderId?: string
如果表头是占位符表头,则这将是一个唯一的表头 ID,不会与表格中的任何其他表头冲突。
getContext
getContext: () => { table: Table<TData> header: Header<TData, TValue> column: Column<TData, TValue>}
返回基于列的组件(如表头、表尾和过滤器)的渲染上下文(或属性)。使用这些属性与您的框架的 flexRender
实用程序一起使用,使用您选择的模板来渲染它们:
flexRender(header.column.columnDef.header, header.getContext())