Docyrus

DataGridViewSelect

Saved-view switcher for a data grid — pill tabs, dropdown or picker sheet, active-view actions, a full-screen view editor with 11 sections and a manage-views sheet. Same API as the web component.

iOSAndroid
Preview DataGridViewSelect on your device

Scan with Expo Go

Download Expo Go, then scan the QR code to preview native components.

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-data-grid-view-select
Required Packages(3 packages)
pnpm add @tanstack/react-table @react-querybuilder/core @docyrus/app-utils

DataGridViewSelect drives the TanStack table of a data grid (from useDataGrid, useDocyrusDataGrid or your own useReactTable): selecting a view applies it with applyViewToTable (visibility, order, pinning, sorting, filters, grouping, row height, display mode, column options). The public API mirrors web @docyrus/ui 1:1 — useDocyrusDataViewSelect returns a ready-made gridViewSelectProps object for it.

Mobile adaptations:

  • Active-view menu — long-press a tab (or the view chip), or tap its ⋯: an ActionSheet with Configure, Rename, Hide, Hidden views, Add view after / before, Duplicate view, Delete (confirmed with DeleteConfirmDialog) and Manage all views. System views (isSystem) only offer Hide, Hidden views and Manage all views.
  • View editor — a full-screen page sheet with an accordion of sections instead of the web two-pane dialog.
  • Manage all views — a bottom sheet with up / down reorder, hide / unhide and delete.
  • Add view — the + button (and the picker sheet's Add view row) opens a quick "name this view" sheet that saves the grid's current layout (captureViewSnapshot); Configure all settings… opens the full editor instead.
  • vertical-tabs (web side panel) renders a trigger chip that opens a picker sheet listing every view.

Usage

import { useDataGrid, DataGrid } from '@/components/docyrus-native/data-grid';
import { DataGridViewSelect, type SavedDataGridView } from '@/components/docyrus-native/data-grid-view-select';

function DealsPage() {
  const grid = useDataGrid({ data, columns });
  const [views, setViews] = useState<SavedDataGridView[]>(initialViews);
  const [activeViewId, setActiveViewId] = useState('all');

  return (
    <>
      <DataGridViewSelect
        table={grid.table}
        variant="horizontal-tabs"
        maxVisibleViews={4}
        views={views}
        activeViewId={activeViewId}
        onViewChange={view => setActiveViewId(view.id)}
        onViewCreate={(view, position) => setViews(prev => insertAt(prev, view, position))}
        onViewSave={view => setViews(prev => prev.map(v => (v.id === view.id ? view : v)))}
        onViewDelete={id => setViews(prev => prev.filter(v => v.id !== id))}
        onViewReorder={ids => setViews(prev => ids.map(id => prev.find(v => v.id === id)!))}
        fields={queryBuilderFields}
        editable />
      <DataGrid {...grid} />
    </>
  );
}

With a Docyrus data source, spread the hook output instead:

const { gridViewSelectProps } = useDocyrusDataViewSelect({ client, appSlug: 'base', dataSourceSlug: 'deal' });

<DataGridViewSelect table={grid.table} {...gridViewSelectProps} variant="horizontal-tabs" editable />

Standalone editor

import { DataGridViewEditor } from '@/components/docyrus-native/data-grid-view-select';

<DataGridViewEditor
  table={table}
  fields={fields}
  onSave={view => createView(view)}
  trigger={<Text>New view…</Text>} />

API Reference

DataGridViewSelect

PropTypeDefaultDescription
tableTable<TData>—Required. The grid's TanStack table. Views are applied to it via applyViewToTable; the editor reads its columns (labels, groups, meta.forcedReadOnly, relation cells, groupable / sortable columns).
viewsSavedDataGridView[]—Required. The saved views (see SavedDataGridView).
variant'dropdown' | 'horizontal-tabs' | 'vertical-tabs' | 'tabs''dropdown'dropdown: view chip + searchable picker sheet. horizontal-tabs: scrollable pill tab strip. vertical-tabs: view chip + picker sheet + add button (web side panel). tabs: deprecated alias of horizontal-tabs.
maxVisibleViewsnumber—horizontal-tabs only. Views past this count move into a More (n) sheet; the active view is swapped onto the strip.
activeViewIdstring—Controlled active view id.
defaultActiveViewIdstring—Initial active view id (uncontrolled). Nothing is active when omitted (web parity).
onViewChange(view: SavedDataGridView) => void—Fires after the selected view was applied to table.
onViewCreate(view: SavedDataGridView, position?: { afterViewId?: string; beforeViewId?: string }) => void—Create from the editor, quick create, Duplicate view (afterViewId = source) and Add view after / before. Omitted → no create affordances.
onViewSave(view: SavedDataGridView) => void—Save from the editor. Also receives renames when onViewRename is omitted.
onViewDelete(viewId: string) => void—Delete (editor button, actions sheet, manage sheet). Always confirmed. Never offered for system views.
onViewHide(viewId: string) => void—Hide a view from the list.
onViewUnhide(viewId: string) => void—Unhide (Hidden views sheet, Manage all views).
hiddenViewIdsstring[]—Ids of hidden views.
onViewReorder(orderedViewIds: string[]) => void—New top-to-bottom order from Manage all views. Omitted → no reorder controls.
onViewRename(viewId: string, name: string) => void—Native convenience for the Rename action. Falls back to onViewSave({ ...view, name }).
fieldsFullField[]—Query-builder fields (@react-querybuilder/core) for the editor's Filters section. Omitted / empty → section hidden.
formsDataForm[]—Saved forms (@docyrus/app-utils) for the editor's Form section. Omitted / empty → section hidden. Archived forms are skipped.
editablebooleanfalseEnables the actions sheet, editor, quick create, and manage sheet.
disabledboolean—Disables every interaction.
placeholderstringui.dataGridView.selectView → 'Select view'Chip label when no view is active.
isSavingboolean—true while a create / save request is in flight. The editor stays open behind a Saving… overlay and closes when it flips back to false. Omitted → the editor closes immediately on Save.
isLoadingboolean—Renders a Loading views… row while views is still empty.
defaultRowGroupingColumnstring—Column id shown as (Default) in the Row Grouping section, with a hint when the view has no grouping.
galleryCardConfigDataGalleryCardConfigSerializable—Live gallery card bindings for the Gallery View section.
galleryDisplayConfigDataGalleryDisplayConfigDEFAULT_DATA_GALLERY_DISPLAY_CONFIGLive gallery layout for the Gallery View section.
onGalleryCardConfigChange(updater: (prev) => DataGalleryCardConfigSerializable) => void—With onGalleryDisplayConfigChange, shows the Gallery View section (edited live — persisted by the host on Save).
onGalleryDisplayConfigChange(updater: (prev) => DataGalleryDisplayConfig) => void—See above.
classNamestring—Root className.

DataGridViewEditor

The full-screen editor (web ViewEditorDialog). DataGridViewSelect mounts it for you; use it directly for custom triggers.

PropTypeDefaultDescription
tableTable<TData>—Required. Source of the column list and defaults.
openboolean—Controlled open state.
onOpenChange(open: boolean) => void—Open state change.
valueSavedDataGridView—The view being edited. Omitted → create mode (defaults from the table's current row height / display mode).
viewsSavedDataGridView[]—Enables the Switch view picker (non-system views) while editing.
onSave(view: SavedDataGridView) => void—Receives the built view.
onDelete(viewId: string) => void—Delete button handler.
onCancel() => void—Cancel handler.
onViewSwitch(viewId: string) => void—Switch view handler (swap value).
fieldsFullField[]—Filters section fields.
formsDataForm[]—Form section forms.
defaultRowGroupingColumnstring—Row Grouping default.
isSavingboolean—Saving overlay + auto-close.
disabledboolean—Disables every control.
showDeleteboolean—Shows the Delete button (edit mode only).
triggerReactNode—Pressable content that opens the editor (uncontrolled use).
galleryCardConfig / galleryDisplayConfig / onGalleryCardConfigChange / onGalleryDisplayConfigChange——Gallery View section (see above).
classNamestring—Sheet body className.

Editor sections

SectionContents
GeneralName + icon picker (Font Awesome / Huge Icons, searchable), description, row height (short / medium / tall / extra-tall), display mode (table / gallery).
ColumnsSearch; Selected columns with remove, pin (writes columnPinning.left in selected order), visibility eye (disabled when the column can't hide) and up / down reorder; Available columns grouped by meta.group with add; Column options — Show autonumber for relation columns (columnOptions[id].showAutonumber).
SortingOrdered sort rules: column, Asc / Desc, reorder, remove, Add sort.
Row GroupingOne groupable column (select, status, relation, date, datetime, user) or No grouping.
PagingActivate paging footer, paging mode (standard / virtual-scroll), page size (DATA_GRID_PAGE_SIZE_OPTIONS).
Inline EditingMaster switch + per-column read-only switches, All editable / All read-only. Columns with meta.forcedReadOnly are locked (metadata badge).
FormBind a saved form (formId) — shown when forms is non-empty.
FiltersNative QueryBuilderDocyrus over fields → filterQuery — shown when fields is non-empty.
Gallery ViewDataGalleryCardConfigMenu + DataGalleryDisplayMenu (live) — shown when both gallery change handlers are set.
Row Color RulesJSONata formula + colour (palette swatches or any hex / Tailwind name such as emerald-500, resolved with resolveColorHex).
Cell Color RulesColumn + JSONata formula + colour.

Everything except Gallery View is a draft emitted only on Save (the Save button needs a name).

SavedDataGridView

FieldTypeDescription
idstringView id.
namestringDisplay name.
descriptionstringOptional description (shown in the picker sheet).
iconstringDocyrus icon ('fal table', 'huge file-01').
columnVisibilityRecord<string, boolean>Column visibility.
columnOrderstring[]Selected columns in order.
columnPinning{ left?: string[]; right?: string[] }Pinned columns (select / actions are kept pinned first by applyViewToTable).
rowHeight'short' | 'medium' | 'tall' | 'extra-tall'Row height.
displayMode'table' | 'gallery'Display mode.
sortingSortingStateSort rules.
columnFiltersColumnFiltersStateColumn (chip) filters — preserved as-is by the editor.
groupingstring[]Row grouping (one column).
filterQueryRuleGroupTypeQuery-builder filter.
rowColorRules{ formula: string; color: string }[]Row colour rules (JSONata).
cellColorRules{ column: string; formula: string; color: string }[]Cell colour rules (JSONata).
pagingEnabledbooleanPaging footer on.
pagingMode'standard' | 'virtual-scroll'Paging layout.
pageSizenumberPage size.
inlineEditingEnabledbooleanInline editing on.
readOnlyColumnsstring[]User-chosen read-only columns (forced ones are recomputed).
columnOptionsRecord<string, { showAutonumber?: boolean }>Per-column display options.
isSystembooleanDeveloper-defined view — can be hidden, never edited / deleted.
isDefaultbooleanInitial view when nothing is persisted.
formIdstringBound saved form.
galleryCardConfigDataGalleryCardConfigSerializableGallery card bindings.
galleryDisplayConfigPartial<DataGalleryDisplayConfig>Gallery layout.

DataGridAdvancedFilter

The grid toolbar's AND / OR filter lives in the data-grid package (@/components/docyrus-native/data-grid) and shares this editor's query builder. See the DataGrid page.

Translations

All copy goes through useUiTranslation() with the web keys — ui.dataGridView.* (e.g. selectView, addView, configure, hideView, hiddenViews, addViewAfter, addViewBefore, duplicateView, deleteView, manageAllViews, editView, newView, saveView, saving, general, columns, sorting, rowGrouping, paging, inlineEditing, form, filters, galleryView, rowColorRules, cellColorRules, …) plus native-only keys renameView, createView, configureAllSettings, moreViews, more, moveUp, moveDown, columnOptions, color, customColorPlaceholder, apply, viewObjectName, deleteViewTitle, rowColorRulesHint, cellColorRulesHint, manageAllViewsDescriptionNative.

Breaking changes (native)

BeforeNow
No table proptable is required — views are applied to it.
views: DataGridView[] (filters / sorting / columns: unknown)views: SavedDataGridView[]. DataGridView type removed.
onViewCreate(name: string)onViewCreate(view: SavedDataGridView, position?) — quick create now sends a full view built from the current table layout.
variant: 'tabs' | 'dropdown', default 'tabs''dropdown' | 'horizontal-tabs' | 'vertical-tabs', default 'dropdown' (web). 'tabs' still works as a deprecated alias.
First view active by defaultNothing active unless activeViewId / defaultActiveViewId is set (web).
Long-press a tab → inline renameLong-press → actions sheet (Rename is one of its actions).
style propRemoved — use className.
Single-file components/data-grid-view-select.tsxMulti-file folder with an index.tsx barrel (same import path).

Type Exports

TypeDescription
DataGridViewSelectProps<TData>Props of DataGridViewSelect.
DataGridViewEditorProps<TData>Props of DataGridViewEditor.
DataGridViewSelectVariant'dropdown' | 'horizontal-tabs' | 'vertical-tabs' | 'tabs'.
DataGridViewCreatePosition{ afterViewId?: string; beforeViewId?: string }.
DataGridGalleryCardConfigUpdater / DataGridGalleryDisplayConfigUpdaterGallery change-handler signatures.
DataGridViewDraftColumnEditor column draft (returned by buildDraftColumns).
SavedDataGridViewRe-exported from the data-grid types.

Also exported: buildDraftColumns(table, view?) — the editor's column list builder.

On this page