getting-started
它能做什么
这项技能展示如何在 Octane 应用中用 TanStack Table 构建数据表格。适合使用 Octane 及其 TSRX 模板语法的开发者。
适用场景
- ✓当你在构建一个用表格显示记录列表的 Octane 页面的时候。
- ✓当你需要通过其渲染辅助函数显示表头和单元格的时候。
- ✓当你想在 TSRX 文件中用列辅助函数定义表格列的时候。
技能链接
https://github.com/TanStack/table/blob/main/packages/octane-table/skills/getting-started/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我正在做一个 Octane 页面,用表格显示产品列表。应该如何设置?”
每周 5 个新技能,1 分钟读完。
工作原理
它提供一个带有列和数据的示例组件,然后在标记中循环遍历表头、行和单元格,将它们显示在页面上。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Load intent load @tanstack/table-core#core first for the headless model, stable inputs, and column inference.
Setup
import { createRoot, useState } from 'octane'
import {
createColumnHelper,
tableFeatures,
useTable,
} from '@tanstack/octane-table'
type Person = { name: string }
const features = tableFeatures({})
const helper = createColumnHelper<typeof features, Person>()
const columns = helper.columns([helper.accessor('name', { header: 'Name' })])
function PeopleTable() @{
const [data] = useState<Person[]>([{ name: 'Ada' }])
const table = useTable({ features, columns, data })
<table>
<thead>
@for (const group of table.getHeaderGroups(); key group.id) {
<tr>
@for (const header of group.headers; key header.id) {
<th><table.FlexRender header={header} /></th>
}
</tr>
}
</thead>
<tbody>
@for (const row of table.getRowModel().rows; key row.id) {
<tr>
@for (const cell of row.getAllCells(); key cell.id) {
<td><table.FlexRender cell={cell} /></td>
}
</tr>
}
</tbody>
</table>
}
const rootElement = document.getElementById('root')
if (!rootElement) throw new Error('Root element not found')
createRoot(rootElement).render(PeopleTable)
Construction and rendering
This adapter distributes authored TypeScript and TSRX. Configure the consumer with octane() in vite.config.ts and the TSRX JSX import source octane. Author component bodies with @{ ... } and keyed @for loops for rows, headers, and cells.
Import from @tanstack/octane-table. Render table.FlexRender as a component so it gets its own Octane scope. It preserves numbers including 0, render descriptors, and component functions.
Keep features and column definitions at module scope. For inputs that depend on component state, use useMemo; pass the current stable data array to useTable. Convert non-renderable values with String(value) when displaying them as text.
Read for the task
- When adding or configuring optional features, load
intent load @tanstack/table-core#table-featuresand read only references for the requested behavior. - For state ownership or reactive reads, read table-state.
- When tables share features, defaults, or reusable UI, read create-table-hook.
API discovery
Inspect node_modules/@tanstack/octane-table/src/index.d.ts, the matching *.tsrx.d.ts sidecar, and src/types.ts. This package publishes authored source; core APIs are in installed @tanstack/table-core/dist/.
常见问题
什么是 TSRX?
示例是用 TSRX 编写的,这是该适配器使用的组件语法,因此看起来与普通 JSX 不同。
表格的数据从哪里来?
示例使用 useState 把数据保存在 Octane 状态中,并将其传给表格。
这会取代核心表格指南吗?
不会,它假设你已经先阅读过核心指南中关于无头表格模型的内容。
详情
作者的原始描述
Create and render Table v9 with the octane adapter. Route reusable createTableHook components, and framework setup; use table-state for reactive ownership.
repo: TanStack/table
热度
- GitHub 星标
- 29k
- 排名
- #9817
- 许可证
- MIT
- 更新时间
- 2026/10/21
评论
- …
同一仓库的更多技能
getting-started
29k教你的智能体如何在 Alpine.js 中使用 TanStack Table 构建并显示数据表格,涵盖设置、响应式数据和渲染行。
table-state
29k教你的智能体如何在 Alpine.js 中读取和控制表格状态,例如当前页码,使状态变化时屏幕能够更新。
devtools
29k教你的智能体如何把 Angular 表格注册到 TanStack Devtools 面板中,使开发者在构建应用时能检查每个表格。
getting-started
29k教你的智能体如何在 Angular 中创建并显示 TanStack 表格,涵盖 injectTable 设置、模板渲染和行数据的更新。