Skip to Content

<resource>-columns.tsx

<resource>-columns.tsx declares a resource’s columns once, shared by the ProTable list, the BetaSchemaForm form and the ProDescriptions detail view.

app/orders/ ├── orders-columns.tsx # order columns ├── page.tsx # <ResourceList columns={orderColumns} /> └── [id:int]/ └── page.tsx # <ResourceDetail columns={orderColumns} />

What it does

Three pro-components read the same column shape. Write the columns once and labels, money formatting, statuses and form rules match on every screen. Adding a field is one edit.

The extension is .tsx because columns often have render functions returning JSX. The file runs in the browser.

Exports

  • A column array typed ProFormColumnsType<T>[], e.g. orderColumns.
  • The row type T if pages need it (Order).

Common keys: title, dataIndex, valueType (text, vnd, vnDate, select, dateTime…), valueEnum, formItemProps.rules, hideInForm, hideInSearch, hideInTable.

Example

app/orders/orders-columns.tsx
import type { ProFormColumnsType } from "@ant-design/pro-components"; import { OrderStatus } from "app/shared/order"; export type Order = { id: number; customerName: string; total: number; status: string; createdAt: number }; export const orderColumns: ProFormColumnsType<Order>[] = [ { title: "No.", dataIndex: "id", hideInForm: true, hideInSearch: true, width: 80 }, { title: "Customer", dataIndex: "customerName", formItemProps: { rules: [{ required: true, max: 200 }] } }, { title: "Total", dataIndex: "total", valueType: "vnd", formItemProps: { rules: [{ required: true }] } }, { title: "Status", dataIndex: "status", valueType: "select", valueEnum: OrderStatus.valueEnum, hideInForm: true }, { title: "Created", dataIndex: "createdAt", valueType: "dateTime", hideInForm: true, hideInSearch: true }, ];

<ResourceList> and <ResourceDetail> from manh/shell read this file to build the table, the add and edit forms and the detail page. A hand-built page passes columns={orderColumns} to ProTable, BetaSchemaForm and ProDescriptions.

vnd shows money as 1.250.000 ₫, vnDate shows dates as 13/11/2026. AppShell registers both types.

Good to know

  • Take status lists from defineEnum in app/shared/; don’t copy a valueEnum into the columns file. Change a label once and every screen follows.
  • A columns file doesn’t import app/db or *.table.ts. Write the row type here or put it in app/shared/.
  • Not every screen is a ProTable. Approval inboxes, kanban boards and booking calendars deserve their own layout.
  • A date field with fieldProps.format submits the formatted string; add a transform that converts to YYYY-MM-DD.

Next steps

  • List pages — use the columns file for a table with status tabs, search and paging.
  • Forms — validation rules, dependent fields and date fields.
  • shared/ — defineEnum for the status lists the columns read.
Last updated