Skip to Content

List pages

A list page shows many records, lets users search, filter by status, and select several rows to act on at once, built with ProTable.

This is where users work every day: an approver opens the request inbox, filters the pending ones, selects a few and approves them in one step. ProTable ships search, pagination, row selection and a toolbar. You declare the columns and how to load the data.

ProTable listList: ProTable with a search form, status tabs with counts, multi-select to approve, valueEnum as Badges.
example.manh.run · sample dataOpen in editor ↗
The example runs when you scroll to it

Declare the columns once

Each column is both a table column and decides whether it becomes a search field. Declare one columns array and reuse it for the table, the search form, and the detail page.

app/requests/page.tsx
const columns: ProColumns<Req>[] = [ { title: "Title", dataIndex: "title", ellipsis: true }, // becomes a search field { title: "Amount", dataIndex: "amount", align: "right", search: false, render: (_, r) => <b>{vnd(r.amount)}</b> }, { title: "Status", dataIndex: "status", valueEnum: STATUS, search: false }, // Badge { title: "Category", dataIndex: "category", valueType: "select", valueEnum: CATEGORY }, { title: "Created", dataIndex: "createdAt", valueType: "dateRange", hideInTable: true, search: { transform: (v) => ({ from: v[0], to: v[1] }) } }, // filter only { title: "Actions", valueType: "option", width: 100, render: (_, r) => [<a key="view" onClick={() => open(r)}>View</a>] }, ];
  • search: false for computed columns or long text.
  • hideInTable: true for fields used only to filter, such as a date range.
  • Use valueEnum / valueType instead of render when you can: you get the Badge, the filter field, and the detail-page display for free.

Load data from the app’s API

request calls the generated API in app/api and returns { data, total, success }. When params changes, the table reloads.

app/requests/page.tsx
const api = useApiClient(); <ProTable<Req> rowKey="id" columns={columns} params={{ tab }} request={async (p) => { const r = await api.requests.list({ page: p.current, pageSize: p.pageSize, status: tab === "all" ? undefined : tab, category: p.category, search: p.title, }); return { data: r.data, total: r.total, success: true }; }} pagination={{ pageSize: 20, showTotal: (t) => `${t} requests` }} />

When the table’s parameter names match the API (no renaming title to search or the tab to status), drop the hand-written request and use request={tableRequest(api.requests.list)} from app/hooks. For a standard list (status tabs, search, a create form, links to the detail page), use ResourceList from manh/shell instead (see Call the API from the UI).

Status tabs with counts

Tabs with counts show users how much work is left, more clearly than a status dropdown. Get the numbers from a stats API; the default tab is the signed-in role’s work (an approver lands on Pending).

app/requests/page.tsx
toolbar={{ menu: { type: "tab", activeKey: tab, onChange: (k) => setTab(k as Tab), items: TABS.map((t) => ({ key: t.key, label: <span>{t.label} <Badge count={counts?.[t.key]} /></span>, })), }, }}

Select several rows to act at once

Turn on rowSelection only for roles that are allowed to act, and disable rows that can no longer be processed.

app/requests/page.tsx
rowSelection={canApprove ? { getCheckboxProps: (r) => ({ disabled: r.status !== "pending" }) } : undefined} tableAlertRender={({ selectedRows }) => <span><b>{selectedRows.length}</b> selected · total <b>{vnd(sum(selectedRows))}</b></span>} tableAlertOptionRender={({ selectedRows, onCleanSelected }) => ( <Space><a onClick={onCleanSelected}>Clear selection</a><BulkApprove rows={selectedRows} /></Space> )}

Good to know

  • An action column pinned to the right (fixed: "right") needs scroll={{ x: 1100 }} on the table.
  • For a list that updates on its own: polling={5000} (minimum 2000 ms).
  • The server must still check permissions and status on approval. Disabling a checkbox only keeps users from clicking by mistake.

Variants

Card list. When each record has an image or progress, use ProList as a grid.

Card listCard list: ProList grid + metas (title, subTitle tag, avatar, description, progress content, actions on hover).
example.manh.run · sample dataOpen in editor ↗
The example runs when you scroll to it

List and detail side by side. A compact table on the left, the detail on the right:

app/requests/page.tsx
<ProCard split="vertical"> <ProCard colSpan="384px" ghost> <ProTable search={false} options={false} columns={columns} request={load} onRow={(r) => ({ onClick: () => setId(r.id) })} /> </ProCard> <ProCard title={current?.title}>{/* ProDescriptions + approve button */}</ProCard> </ProCard>

Inline-editable table. Use EditableProTable with editable={{ type: "multiple", editableKeys, onChange, onSave }}.

Next steps

Last updated