框架
版本
企业版

行 API

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

行 API

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

id

tsx
id: string
id: string

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

depth

tsx
depth: number
depth: number

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

index

tsx
index: number
index: number

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

原始

tsx
original: TData
original: TData

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

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

父级ID

tsx
parentId?: string
parentId?: string

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

获取值

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

返回行中给定 columnId 的值。

渲染值

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

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

获取唯一值

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

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

子行

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

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

获取父行

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

返回行的父行,如果存在。

获取父行们

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

返回行的所有父行,直到根行。

获取叶子行

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

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

原始子行

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

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

获取所有单元格

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

返回行中的所有 单元格

我们的合作伙伴
Code Rabbit
AG Grid
订阅 Bytes

您的每周 JavaScript 资讯。每周一免费发送给超过 10 万开发者。

Bytes

无垃圾邮件。您可以随时取消订阅。

订阅 Bytes

您的每周 JavaScript 资讯。每周一免费发送给超过 10 万开发者。

Bytes

无垃圾邮件。您可以随时取消订阅。