11 KiB
TablePro Live Examples
Start with a bare table and add queries, pagination, column settings, or printing as needed. These examples use real Ray Admin components and demo data. Run example loads each interactive area without sign-in or a business API. On narrow screens, scroll inside the table or open a new tab. Each example includes the source that actually runs.
| Goal | Start here |
|---|---|
| Display rows you already have | Bare table and local sorting |
| Use the current page and total returned by an API | Remote queries and retry |
| Let a page or query library own data and pagination | Manual remote pagination |
| Combine filters, validation, and remote options | Advanced search |
| Fill the workspace and handle many columns or rows | Automatic height and virtual scrolling · Column settings and persistence |
| Customize actions or export print and CSV | Custom slots and row menu · Printing and CSV |
| Control the table from the page | Instance methods and hooks |
Bare table and local sorting
Click Age to cycle through ascending, descending, and default order. The table consumes the ten supplied rows. bare hides the title and toolbar and disables pagination by default. scrollX preserves column widths in a wide table.
::: details View the bare table source <<< ../../../admin/src/views/demo/tables/basic.tsx :::
Remote queries and retry
- Copy part of a row's name or email into the filter area and submit. The query returns to page 1 and pagination uses the filtered total.
- Clear the filters, sort by Age, and change pages.
onUpdateSortermaps the sort toparams.sortAge, which applies to the full result set before pagination. - Select rows on two pages. The toolbar shows the total across pages. More actions → Export CSV exports visible data columns on the current page.
- Click Simulate request failure to see the old rows clear and an error appear. Click Refresh to recover. Forward
request'ssignalto the HTTP client for cancellation.
::: details View the remote query source <<< ../../../admin/src/views/demo/tables/remote.tsx :::
Manual remote pagination
This example simulates an external API with local data and supplies only the current page. Go to page 2 and filter by name. The page returns to 1 and the total changes. Changing page size also returns to page 1.
The page owns page, pageSize, and itemCount and updates them from pagination callbacks and onSearch. For an async service, manage loading, cancellation, and errors in that layer. Use request from the previous example to let TablePro own these states.
::: details View the controlled pagination source <<< ../../../admin/src/views/demo/tables/controlled.tsx :::
Advanced search
Switch between local matching and a mock remote query. After each action, compare the draft, applied filters, transformed parameters, and actual list request.
- Combine filters. Submit multiple statuses and a creation date range. The remote query splits the dates into
createdFromandcreatedTo. Page changes reuse the parameters. - Dependencies and cancellation. Switch quickly between North and South. The owner draft clears and the previous options request is canceled. Search South's options for Wang.
- Zero and boolean values. Apply the delivery and amount scenario and expand an order. Follow the product cascader, warehouse tree, delivery control, and datetime field. Confirm
minAmount: 0andinvoiced: falseare preserved. - Validation and automatic apply. Submit a one-character keyword and check that existing rows remain. Correct it, enable automatic submission on input, and edit repeatedly to see the debounce.
- Recover independent failures. Fail the owner options or list request once. Retry options at the field, or resubmit the list query.
::: details View the search example, business API, and demo fixtures <<< ../../../admin/src/views/demo/tables/search.tsx
<<< ../../../admin/src/api/demo/data.ts
<<< ../../../../packages/demo-data/src/orders.ts :::
Automatic height and virtual scrolling
Enable Virtual rows, then show the footer and action slots. The list gives the new content room while the paginator stays below the rows. Open the example in a new tab and resize its height. Compare the available space with filters expanded and collapsed. Virtual scrolling reduces the rendered row count. The current page, loaded rows, and export scope are calculated as usual.
::: details View the automatic height source <<< ../../../admin/src/views/demo/tables/auto-height.tsx :::
Column settings and persistence
- Open Column settings. Hide Name and Email. The Contact details group disappears once both children are hidden.
- Drag root columns or use the move buttons. Columns with widths can be pinned to the start or end. Enable resizing, then drag a header edge.
- Click Reset column layout to restore initial order, pinning, and width settings while keeping visibility.
- Open the example in a new tab, hide a column, and reload that same tab.
columnStateKeysaves visibility in a separate session namespace. Production applications can include the tenant or account ID in the key. - Toggle Include the ID field to change the column definitions. Data columns and groups use stable keys. Selection columns are outside visible data column settings.
::: details View the column settings source <<< ../../../admin/src/views/demo/tables/columns.tsx :::
Custom slots and row menu
Filter by email in the custom form, which submits through submit(values) from filters. Use the title actions to return to page 1 and set 20 rows per page. Select rows and clear them with the bottom action. Right-click a row to run a sample menu action. The callback receives the row's data.
::: details View the custom slot source <<< ../../../admin/src/views/demo/tables/custom.tsx :::
Copy an image
Click Copy table image in any full table above and paste it into an image-capable chat or document. Try hiding or pinning columns, or scrolling horizontally, before copying. Virtual scrolling captures only the content currently rendered in the visible table area. The copy action is on by default and can be hidden with showCopyImage={false}. Printing is off by default.
Printing and CSV
This example sets showPrint. Filter by name or hide a column in Column settings. Choose More actions → Print table to preview the current page's visible data columns. Print a separate summary previews a custom region supplied via print({ target }). Cancel the browser dialog to preview without printing.
::: details View printing source and styles <<< ../../../admin/src/views/demo/tables/printing.tsx
<<< ../../../admin/src/views/demo/tables/printing.scss :::
To compare both CSV scopes, download the files in Export, print, and the instance lifecycle.
Instance methods and hooks
Query, retry, and pagination
Go to page 2 and compare Refresh current page with Refresh from page 1. Simulate failure and observe queryState loading, failure, and totals, then refresh to recover. Submitting a name filter displays the actual request parameters. Change pages rapidly to see the latest request win.
::: details View the query hook source <<< ../../../admin/src/views/demo/tables/hooks-query.tsx :::
Cross-page selection and bulk actions
Use Select current page on two pages, then Deselect current page. Only that page's keys are removed. Mark the remaining selected rows and return to the relevant page to check them. Sort rows, then use Clear sorting to see how the example calls the underlying method exposed by getTableInstance().
::: details View the selection hook source <<< ../../../admin/src/views/demo/tables/hooks-selection.tsx :::
Export, print, and the instance lifecycle
Download Export current page as CSV and Export all loaded rows as CSV, then compare the row counts. The latter uses keepOriginalData to export the entire supplied batch. In remote mode it does not fetch other pages. Click Unmount table to disable the actions, then mount it again to re-register the instance.
::: details View the output hook source <<< ../../../admin/src/views/demo/tables/hooks-output.tsx :::