Hooks

useDocyrusDataTable

Headless Docyrus-backed table for the native DataTable — schema columns rendered with the value renderers, server filters / sort / search / paging, saved views, bulk actions, exports and a table ↔ gallery view node.

iOSAndroidExpo Go

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-docyrus-data-table
Required Packages(5 packages)
pnpm add @docyrus/app-utils @docyrus/api-client @tanstack/react-query @tanstack/react-table @react-querybuilder/core

A port of the web hook with the same options and result. It builds its own useReactTable instance (no grid editing controller) whose cells render through the native value renderers, and returns table + tableProps for the headless native DataTable, a toolbar, and a view node that switches between the table and a card gallery. It shares the saved views, list-params, export and bulk-action engine with useDocyrusDataGrid.

Overview

  • Columns — one column per schema field whose cell is the field's value renderer (VALUE_RENDERER_MAP); object values group by a stable key. inferColumnsFromData derives columns from the rows when there is no schema.
  • Items query — GET /v1/apps/{appSlug}/data-sources/{dataSourceSlug}/items (or collection.list) with a flat columns list, expand, orderBy (sorting is manual for server data), filters (saved view + toolbar chips + listParams.filters), debounced filterKeyword, limit / offset / fullCount in standard paging.
  • Saved views — DataGridViewSelect in the toolbar; the active view is applied like the grid hook (reserved columns pinned left). pinLeadingColumns pins select / actions / __* columns on view-less tables.
  • Display mode — enableDisplayMenu adds the table / gallery toggle; view renders DataTable or the native DataGridGallery (legacy cardConfig adapted with adaptLegacyCardConfig, pull-to-refresh → records reload).
  • Bulk actions — selection bar inside toolbar (update / delete / export / email / message + extraBulkActions).
  • Persistence — persistState per active view (search, filters, sort, grouping, display mode, column layout, page size).

Usage

import { View } from 'react-native';

import { useDocyrusClient } from '@docyrus/signin/react-native';

import { useDocyrusDataTable } from '@/hooks/docyrus-native/use-docyrus-data-table';

export function OrganizationsTable() {
  const client = useDocyrusClient();
  const { toolbar, view } = useDocyrusDataTable({
    client: client!,
    appSlug: 'base',
    dataSourceSlug: 'organization',
    enableDisplayMenu: true,
    persistState: true,
    cardConfig: { titleField: 'name', descriptionField: 'email' },
    onRowClick: row => console.log(row.original)
  });

  return (
    <View className="flex-1">
      {toolbar}
      {view}
    </View>
  );
}

Render <DataTable table={table} {...tableProps} /> yourself instead of view when you don't need the gallery toggle.

API Reference

Options (UseDocyrusDataTableOptions<TData>)

Every useDocyrusDataViewSelect option is accepted and forwarded, plus:

OptionTypeDefaultDescription
dataTData[]—Pre-resolved rows (skips the items query; search filters client-side).
collectionDocyrusDataGridCollection<TData>—{ list, updateMany?, deleteMany? }.
listParamsDocyrusDataGridListParams—Extra items params (filters AND-merged).
defaultLimitnumber100Default page size.
enableItemsQuerybooleandata === undefinedToggle the items query.
pagingMode'standard' | 'virtual-scroll'viewForce the paging mode.
pageSizenumberview / defaultLimitStandard-paging page size without a view.
showSelectColumnbooleantrueLeading select column.
enableRowNumbersbooleantrueRow numbers on the select column.
selectColumn / actionsColumnColumnDef<TData>—Replace the select column / add an actions column.
extraColumnsColumnDef<TData>[]—Columns before the field columns.
pinLeadingColumnsbooleanfalsePin utility columns left when no view is active.
mapColumn(field, defaultColumn) => ColumnDef | null—Per-field override.
inferColumnsFromDatabooleanfalseColumns from row keys when there's no schema.
onRowClick(row: Row<TData>) => void—Row press (table) / card press (gallery).
usersCellUserOption[]—Users for the user filter options.
getRelationHref / onOpenRelationrelation navigation—Forwarded to tableMeta.
formatDate / formatDateTime / formatNumberformatterscontextTenant formatters (default: providers when mounted).
initialStatePartial<{ sorting; columnFilters; columnVisibility; rowSelection; expanded; grouping; pagination }>—Initial TanStack state.
enableViewSelect / viewSelectVariant / viewSelectMaxVisibleview pickertrue / 'horizontal-tabs'View picker ('vertical-tabs' omits it on native).
enableSearchInputbooleantrueSearch input.
searchPlaceholder / searchDebounceMsstring / numbert('ui.common.search', 'Search...') / 300Search config.
enableFilterMenu / enableGroupMenu / enableSortMenubooleantrueMenu triggers.
enableDisplayMenubooleanfalseTable / gallery toggle.
defaultDisplayMode'table' | 'gallery''table'Initial display mode.
displayMode / onDisplayModeChangecontrolled display mode—Controlled pair.
cardConfigDataGridCardConfig<TData>—Gallery card config (titleField, descriptionField, imageField, bodyFields, renderCard).
galleryHeightnumber | 'auto''auto'Gallery height ('auto' fills the parent).
galleryClassNamestring—Gallery container classes.
enableReloadButton / onReloadreloadtrueRecords-only reload.
enableServerExportMenubooleantrueServer export menu.
serverExportLimit / serverExportExcludedFieldTypes / serverExportExcludedSlugsexport config10000 / internalServer export.
toolbarClassName / toolbarStartContent / toolbarEndContenttoolbar—Toolbar customization.
bulkActionsfalse | DocyrusDataGridBulkAction[]all fiveSelection actions.
extraBulkActionsDataGridAction<TData>[]—Appended selection actions.
exportColumns / exportFileNameexport'visible' / dataSourceSlugBulk export columns / file name.
renderBulkUpdateDialog / renderEmailComposeDialog / renderMessageComposeDialogrender slotsnative dialogsNative. Replace the default BulkUpdateDialog / EmailComposeDialog / InstantMessageComposeDialog.
onBulkEmail / onBulkMessagecallbacks—Native. Same as the grid hook; also used by email / phone cells.
tableClassName / tableContainerClassName / emptyTextDataTable props—Forwarded through tableProps.
persistStateboolean | { storage?; key? }—Persist view parameters.
enableSideFiltersbooleanfalseRender sideFilters and AND its rule group into the items query.
sideFiltersConfigDocyrusDataTableSideFiltersConfig<TData>—Same shape as the grid hook's DocyrusDataGridSideFiltersConfig (incl. native presentation: 'sheet' | 'inline').
sideFiltersDefaultExpandedbooleantrueInitial expanded state of the inline panel.
sideFiltersExpanded / onSideFiltersExpandedChangecontrolled state—Inline panel expanded state.
sideFiltersWidthnumber | string280Expanded inline panel width.

Result (UseDocyrusDataTableResult<TData>)

All useDocyrusDataViewSelect result fields except gridViewSelectProps, plus:

FieldTypeDescription
tableTable<TData>TanStack table (useReactTable).
tablePropsobjectclassName, containerClassName, emptyText, pagination, isLoading, isReloading, onRowClick — spread onto DataTable (minus isReloading).
toolbarReactNodeControls + selection bar + bulk dialogs.
viewReactNodeDataTable or the card gallery.
displayMode / setDisplayMode'table' | 'gallery' / setterCurrent display mode.
itemsTData[]Rows.
resolvedListParamsDocyrusDataGridListParamsParams sent.
pagingMode'standard' | 'virtual-scroll' | undefinedResolved paging mode.
reload() => voidFull refetch.
sidePanelReactNodeDataGridSidePanel with the vertical-tabs view picker (viewSelectVariant === 'vertical-tabs'), else null.
sideFiltersReactNodeDataTableSideFilters (sheet trigger by default), or null.
sideFiltersExpanded / setSideFiltersExpandedboolean / setterInline panel state.
sideFiltersQueryRuleGroupType | undefinedRule group emitted by the side filters.

Native deltas

  • view renders the native headless DataTable or the native DataGridGallery (FlashList of DataGalleryCards, pull-to-refresh wired to the records reload).
  • Email / phone value renderers open the native compose dialogs from client (like web); a host override (onBulkEmail / renderEmailComposeDialog, or the message pair) wins through onComposeEmail / onSendMessage.
  • Bulk actions: same native engine as the grid hook (update / email / message open the native dialogs; export via ActionSheet + share sheet).
  • User / relation option loaders resolve relation targets through the shared inventory (web table fetches /v1/apps/data-sources).
  • Side filters default to a sheet trigger (presentation: 'inline' for the web column); the vertical-tabs sidePanel opens its view list as a bottom sheet on phones.

Type Exports

TypeDescription
UseDocyrusDataTableOptions / UseDocyrusDataTableResultOptions / result.
DocyrusDataTableSideFiltersConfigSide-filter config (parity).

On this page