# useLocalDataSourceDataGrid URL: /docs/native/hooks/use-local-data-source-data-grid Run the full useDocyrusDataGrid workflow — views, search, filters, grouping, sort, inline save, bulk delete — over an in-memory LocalDataSource. No backend, no sign-in. ## Installation ```bash pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-local-data-source-data-grid ``` **Dependencies:** - [@tanstack/react-query](https://tanstack.com/query/latest) - [@tanstack/react-table](https://tanstack.com/table/latest) - [jsonata](https://www.npmjs.com/package/jsonata) A verbatim port of the web adapter. It needs a `QueryClientProvider` above it (the grid hook uses TanStack Query even for local data) but no Docyrus client or sign-in. ## Overview `useLocalDataSourceDataGrid` connects a [`LocalDataSource`](/docs/native/hooks/use-local-data-source) to [`useDocyrusDataGrid`](/docs/native/hooks/use-docyrus-data-grid): - `dataSource.client` (a stub client that answers the metadata / view calls) is the grid's `client`; the app / data-source slugs come from the local schema (`'local'` fallback). - `dataSource.list` / `updateMany` / `deleteMany` become the grid `collection`, so the local query engine plays the `/items` endpoint — `filterKeyword`, `filters`, `formulas` (JSONata), `calculations`, `orderBy`, `limit` / `offset` behave like the server. - Columns come from the local field metadata; `systemViews` feed the native `DataGridViewSelect`. - Inline change save and bulk delete write through the local collection. - The server export menu is **off** by default (`enableServerExportMenu: false`). ## Usage ```tsx import { useMemo, useState } from 'react'; import { View } from 'react-native'; import { DataGrid, type SavedDataGridView } from '@/components/docyrus-native/data-grid'; import { useLocalDataSource } from '@/hooks/docyrus-native/use-local-data-source'; import { useLocalDataSourceDataGrid } from '@/hooks/docyrus-native/use-local-data-source-data-grid'; type Deal = { id: string; account: string; stage: string; amount: number; probability: number }; const FIELDS = [ { slug: 'id', name: 'ID', type: 'field-identity', readOnly: true }, { slug: 'account', name: 'Account', type: 'field-text' }, { slug: 'stage', name: 'Stage', type: 'field-select' }, { slug: 'amount', name: 'Amount', type: 'field-money' }, { slug: 'probability', name: 'Probability', type: 'field-percent' } ]; const VIEWS: Array ); } ``` Keep `systemViews`, `listParams`, `toolbarStartContent` and `toolbarEndContent` referentially stable (module constants or `useMemo`) — they take part in view and query synchronization. ## API Reference ### Options (`UseLocalDataSourceDataGridOptions`) | Option | Type | Default | Description | |--------|------|---------|-------------| | `dataSource` | `LocalDataSource` | — | From `useLocalDataSource` / `createLocalDataSource`. Required. | | `listParams` | `LocalDataSourceQueryParams` | — | Local query params merged over the view / search / filter params (formulas, calculations, …). | | `enableServerExportMenu` | `boolean` | `false` | Server export is off for local data. | | `...gridOptions` | `Omit, 'client' \| 'appSlug' \| 'dataSourceSlug' \| 'collection' \| 'listParams' \| 'dataSource'>` | — | Every other [`useDocyrusDataGrid` option](/docs/native/hooks/use-docyrus-data-grid#options-usedocyrusdatagridoptionstdata) — `systemViews`, toolbar toggles, `readOnly`, `trackChanges`, `bulkActions`, `persistState`, … | ### Result `UseDocyrusDataGridResult` — see [`useDocyrusDataGrid`](/docs/native/hooks/use-docyrus-data-grid#result-usedocyrusdatagridresulttdata) (`table`, `gridProps`, `toolbar`, `items`, `resolvedListParams`, `views`, `activeViewId`, `reload`, …). ## Native deltas None beyond the ones [`useDocyrusDataGrid`](/docs/native/hooks/use-docyrus-data-grid#native-deltas) lists. Row ids from `useLocalDataSource` use the optional `expo-crypto` `randomUUID` when installed. ## Type Exports | Type | Description | |------|-------------| | `UseLocalDataSourceDataGridOptions` | Hook options. |