框架
版本
企业版

行 API

这些是所有行的核心选项和 API 属性。 更多选项和 API 属性适用于其他 表格功能

行 API

所有行对象都具有以下属性

id

tsx
id: string
id: string

通过 options.getRowId 选项解析的行的已解析唯一标识符。 默认为行的索引(如果是子行,则为相对索引)。

深度

tsx
depth: number
depth: number

行的深度(如果嵌套或分组),相对于根行数组。

索引

tsx
index: number
index: number

行在其父数组(或根数据数组)中的索引。

原始数据

tsx
original: TData
original: TData

提供给表格的原始行对象。

🧠 如果该行是分组行,则原始行对象将是该组中的第一个原始对象。

parentId

tsx
parentId?: string
parentId?: string

如果是嵌套的,则为此行的父行 ID。

getValue

tsx
getValue: (columnId: string) => TValue
getValue: (columnId: string) => TValue

返回行中给定 columnId 的值

renderValue

tsx
renderValue: (columnId: string) => TValue
renderValue: (columnId: string) => TValue

渲染行中给定 columnId 的值,但如果未找到值,将返回 renderFallbackValue

getUniqueValues

tsx
getUniqueValues: (columnId: string) => TValue[]
getUniqueValues: (columnId: string) => TValue[]

返回行中给定 columnId 的唯一值数组。

subRows

tsx
type subRows = Row<TData>[]
type subRows = Row<TData>[]

options.getSubRows 选项返回和创建的行的子行数组。

getParentRow

tsx
type getParentRow = () => Row<TData> | undefined
type getParentRow = () => Row<TData> | undefined

返回行的父行(如果存在)。

getParentRows

tsx
type getParentRows = () => Row<TData>[]
type getParentRows = () => Row<TData>[]

返回行的父行,一直到根行。

getLeafRows

tsx
type getLeafRows = () => Row<TData>[]
type getLeafRows = () => Row<TData>[]

返回行的叶子行,不包括任何父行。

originalSubRows

tsx
originalSubRows?: TData[]
originalSubRows?: TData[]

options.getSubRows 选项返回的原始子行数组。

getAllCells

tsx
type getAllCells = () => Cell<TData>[]
type getAllCells = () => Cell<TData>[]

返回行的所有 单元格

订阅 Bytes

您每周的 JavaScript 新闻。 每周一免费发送给超过 100,000 名开发者。

Bytes

没有垃圾邮件。 随时取消订阅。