Command palette

@yasinsensoy/native

React Native · Components

DataGrid

Data grid: sorting, filters, search, grouping, trees, detail rows, editing, selection, pinned columns, pagination and infinite scroll.

24 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

Orders
Drag a column header here to group
1,000 records

Code

import { DataGrid, Badge } from "@yasinsensoy/native";

const [rows, setRows] = useState(orders);

<DataGrid
  title="Orders"
  rows={rows}
  rowKey="id"
  selection="multiple"
  groupable
  storageKey="orders"
  height={520}
  onCellsChange={(changes) => setRows((old) => uygula(old, changes))}
  columns={[
    { key: "no", header: "Order", width: 120, pinned: "start" },
    { key: "customer", header: "Customer", flex: 1, editable: true, validate: (v) => (v ? null : "Zorunlu") },
    { key: "city", header: "City", type: "select", options: cities, editable: true },
    { key: "status", header: "Durum", type: "select", options: durumlar, render: ({ value }) => <Badge>{value}</Badge>, aggregate: "count" },
    { key: "date", header: "Tarih", format: "date" },
    { key: "total", header: "Tutar", format: "currency", aggregate: "sum", editable: true },
    { key: "discount", header: "Discount", format: "percent", aggregate: "avg" },
    { key: "paid", header: "Paid", type: "boolean", editable: true },
  ]}
/>

Events

  1. Events appear here when you interact with the preview.

Tree data (file explorer, folders load when opened)

3 records

Server mode (sorting, filter, search, paging on the server)

0 records
Per page

Infinite scrolling

60 records

Import

import { DataGrid } from "@yasinsensoy/native";

DataGrid

component

Data grid: sorting, filters, search, grouping, trees, detail rows, editing, selection, pinned columns, pagination and infinite scroll. Same API and the same data processing core as DataGrid on web; adapted for phones:

  • Rows are in a virtual list (smooth with thousands of rows); columns scroll horizontally, pinned columns stay in place with the native driver.
  • Tapping a header sorts; the header menu has sort, filter, pin, move, group and hide. Dragging its right edge changes the width.
  • Tapping an editable cell opens the editor in a bottom sheet; a yes/no cell toggles directly. Undo/redo is in the toolbar.
  • Long-pressing a row opens the menu (contextMenu) or selects in multiple selection. Export sends the CSV via the share sheet.
  • Looks the same on iOS and Android.
DataGrid(props: DataGridProps<T>): JSX.Element

Examples

<DataGrid
  rows={orders}
  rowKey="id"
  style={{ flex: 1 }}
  selection="multiple"
  columns={[
    { key: "no", header: "No", width: 90, pinned: "start" },
    { key: "customer", header: "Customer", flex: 1 },
    { key: "total", header: "Total", format: "currency", aggregate: "sum" },
    { key: "status", header: "Status", type: "select", options: ["New", "Shipped"] },
  ]}
/>

Parts of the toolbar.

NameTypeDefaultDescription
search?booleantrueSearch box.
columns?booleantrueThe "Columns" panel.
density?booleantrueDensity menu.
export?booleantrueExport (CSV, via the share sheet).

Pagination settings.

NameTypeDefaultDescription
page?numberPage in controlled use (starts at 1).
defaultPage?number1First page in uncontrolled use.
onPageChange?(page: number) => voidCalled when the page changes.
pageSize?numberPage size in controlled use.
defaultPageSize?number50Page size in uncontrolled use.
onPageSizeChange?(size: number) => voidCalled when the page size changes.
pageSizeOptions?readonly number[]Page size options (the first value becomes the default).

Styles of the inner parts of DataGrid.

NameTypeDescription
toolbar?ViewStyleToolbar.
header?ViewStyleHeader row.
row?ViewStyleData row.
cell?TextStyleCell text.
footer?ViewStyleFooter total row.

DataGridProps

interface

Props of the DataGrid component (same names as on web).

NameTypeDefaultDescription
columnsreadonly DataGridColumn<T>[]Columns. See DataGridColumn.
rowsreadonly T[]Rows. For tree data only the root nodes.
rowKey?keyof T | ((row: T) => DataGridKey)Unique key of a row: a field name or a function. If omitted the id field is used, or the index if that is missing (give a key for editing and selection).
label?stringScreen reader name of the table. Give it when there is no visible title.
title?ReactNodeTitle at the start of the toolbar.
actions?ReactNodeYour own buttons to add at the end of the toolbar.
toolbar?boolean | DataGridToolbartrueToolbar. false hides it; an object picks the parts.
density?DataGridDensityDensity in controlled use.
defaultDensity?DataGridDensity"standard"Initial density in uncontrolled use.
onDensityChange?(density: DataGridDensity) => voidCalled when the density changes.
rowHeight?numberRow height (dp); overrides the density. Densities are taller than on web so rows are comfortable to tap: 40, 48, 56.
gridLines?"horizontal" | "both" | "none""horizontal"Cell lines.
striped?booleanfalseAlternating row colors.
sort?DataGridSortSorting in controlled use.
defaultSort?DataGridSortInitial sorting in uncontrolled use.
onSortChange?(sort: DataGridSort) => voidCalled when the sorting changes.
multiSort?booleantrueSorting by multiple columns ("Add to sort" in the column menu).
filters?DataGridFiltersFilters in controlled use.
defaultFilters?DataGridFiltersInitial filters in uncontrolled use.
onFiltersChange?(filters: DataGridFilters) => voidCalled when the filters change.
search?stringGlobal search in controlled use.
defaultSearch?stringInitial search in uncontrolled use.
onSearchChange?(search: string) => voidCalled when the search changes.
columnState?DataGridColumnStateColumn layout in controlled use. See DataGridColumnState.
defaultColumnState?DataGridColumnStateInitial column layout in uncontrolled use.
onColumnStateChange?(state: DataGridColumnState) => voidCalled when the column layout changes.
storageKey?stringWhen given, the column layout and density are stored in storage under this name; the user's layout comes back when the app is reopened.
storage?PreferenceStorageStorage for storageKey (e.g. @yasinsensoy/native/storage). Defaults to memory.
selection?"none" | "single" | "multiple""none"Row selection. "multiple" adds a checkbox column (long-pressing a row also selects); "single" selects when a row is tapped.
selectedKeys?readonly DataGridKey[]Selected keys in controlled use.
defaultSelectedKeys?readonly DataGridKey[]Initially selected keys in uncontrolled use.
onSelectionChange?(keys: DataGridKey[], rows: T[]) => voidCalled with the keys and rows when the selection changes.
isRowSelectable?(row: T) => booleanWhether a row can be selected.
groupable?booleanfalseEnables grouping from the column menu.
groupBy?readonly string[]Grouping columns in controlled use.
defaultGroupBy?readonly string[]Initial grouping in uncontrolled use.
onGroupByChange?(groupBy: string[]) => voidCalled when the grouping changes.
getChildren?(row: T) => readonly T[] | undefinedTree data: the child rows of a row.
loadChildren?(row: T) => Promise<readonly T[]>Loads child rows on first expand (e.g. from the server).
hasChildren?(row: T) => booleanWith loadChildren: can the node have child rows? If omitted all can expand.
treeColumn?stringThe first visible columnColumn the tree indentation is drawn in.
expandedKeys?readonly DataGridKey[]Expanded tree nodes in controlled use.
defaultExpandedKeys?readonly DataGridKey[]Initially expanded nodes in uncontrolled use.
onExpandedChange?(keys: DataGridKey[]) => voidCalled when the expanded nodes change.
renderDetail?(row: T) => ReactNodeDetail panel that opens below a row. When given an expand/collapse column is added.
detailHeight?number160Height of the detail panel before it is measured (dp).
onCellsChange?(changes: DataGridCellChange<T>[]) => unknownCalled with the list of changes when a cell is edited (an editor opens on tap; yes/no toggles directly); you update the rows. If it returns a Promise the cell shows "saving", and an error is shown if it rejects.
onRowClick?(row: T) => voidCalled when a row is tapped.
getRowStyle?(row: T) => ViewStyle | undefinedStyle to add to a row's container.
onRowReorder?(row: T, target: T, position: "before" | "after") => voidReordering rows by long-pressing and dragging the handle. On release it is called with the moved row, the target row and the position. Disabled while grouping.
contextMenu?false | ((context: DataGridContextMenuContext<T>) => readonly MenuEntry[])Menu that opens when a row is long-pressed. false turns it off.
mode?"client" | "server""client""server": no filtering, searching, sorting or paging is done; changes are reported via on…Change and you pass the rows from the server in rows.
rowCount?numberTotal record count in server mode.
loading?booleanLoading indicator (a thin bar on top; a skeleton when there are no rows).
onLoadMore?() => voidInfinite scroll: called when nearing the end. Give it together with hasMore.
hasMore?booleanWhether there are more rows.
pagination?boolean | DataGridPaginationPagination. true enables it with default settings. See DataGridPagination.
footer?booleantrueFooter total row (when columns have aggregate).
statusBar?booleantrueStatus bar (record and selection count).
empty?ReactNodeContent shown when there are no rows.
locale?stringLanguage used for formatting. Defaults to the UIProvider language.
currency?stringCurrency. Defaults to the UIProvider currency.
exportFileName?stringName of the exported file (without extension). Defaults to the exportFileName text ("tablo" in Turkish).
messages?Partial<DataGridMessages>Texts. If omitted, Turkish or English depending on the language.
apiRef?Ref<DataGridApi<T>>Functions that can be called from outside. See DataGridApi.
style?StyleProp<ViewStyle>Root style; the height comes from here (or from the container's flex).
styles?DataGridStylesStyles of the inner parts.
testID?stringTest id.

Row key.

type DataGridKey = string | number

Data type of a column. Decides the filter operators, the editor, alignment, how pasted text is parsed and sorting.

  • "text": Text (default).
  • "number": Number; automatic when format is number | currency | percent.
  • "date": Date (Date or ISO string); automatic when format is date | datetime.
  • "boolean": Yes/No; drawn as a checkbox.
  • "select": A value from options.
type DataGridColumnType = "text" | "number" | "date" | "boolean" | "select"

An option of a "select" column.

NameTypeDescription
valuestringValue stored in the row.
label?stringDisplay name.

A DataGrid column (same fields as on web). Instead of the classes on web there are cellStyle and headerStyle.

Extends: Core.DataGridColumn<T, ReactNode, TooltipProp>

NameTypeDescription
cellStyle?TextStyle | ((row: T, value: unknown) => TextStyle | undefined)Style of the cell text; when a function, based on the row and value.
headerStyle?TextStyleStyle of the header text.

Built-in aggregation functions.

type DataGridAggregateName = "sum" | "avg" | "min" | "max" | "count"

Aggregation of a column: shown in group rows and the summary row. A built-in name or a (values, rows) => result function.

type DataGridAggregate = DataGridAggregateName | ((values: unknown[], rows: readonly T[]) => unknown)

Information for the menu opened by a long press.

type DataGridContextMenuContext = Core.DataGridContextMenuContext<T, DataGridColumn<T>>

Info passed to the DataGridColumn render function.

NameTypeDescription
rowTRow.
valueunknownRaw value of the cell (value or row[key]).
textstringFormatted text (format applied).
rowKeyDataGridKeyKey of the row.
depthnumberDepth of the row in tree data (root is 0).

Info passed to the DataGridColumn editor function.

NameTypeDescription
rowTRow being edited.
valueunknownCurrent value in the editor.
onChange(value: unknown) => voidChanges the value (does not save yet).
commit(value?: unknown) => voidSaves the value and leaves editing. When a value is given, it is set first. When validation fails, editing continues.
cancel() => voidDrops the change and leaves editing.
errorstring | nullValidation error (if any).
typedbooleanEditing started by pressing a letter (the value was replaced by that letter).
inputProps{ autoFocus: true; "aria-label": string; "aria-invalid": boolean | undefined; }Id and ARIA props to pass to the editor.

Sorting of one column.

NameTypeDescription
keystringThe column's key.
direction"asc" | "desc"Direction.

Sorting: columns in priority order. Shift-clicking a header adds a second, third column.

type DataGridSort = readonly DataGridSortItem[]

Filter operator.

  • Text: contains, notContains, equals, notEquals, startsWith, endsWith
  • Number and date: equals, notEquals, gt, gte, lt, lte, between
  • Select, yes/no and value list: in
  • All: empty, notEmpty
type DataGridFilterOperator = "contains" | "notContains" | "equals" | "notEquals" | "startsWith" | "endsWith" | "gt" | "gte" | "lt" | "lte" | "between" | "in" | "empty" | "notEmpty"

Filter of one column.

NameTypeDescription
operatorDataGridFilterOperatorOperator.
value?unknownValue. An array of values for in; a "2026-10-30" string for dates.
value2?unknownUpper bound of the between operator.

Filters by column key.

type DataGridFilters = Readonly<Record<string, DataGridFilter>>

Column layout changed by the user. Can be stored in the browser with storageKey or kept on your side with columnState.

NameTypeDescription
order?readonly string[]Order of column keys. Missing ones are appended.
widths?Readonly<Record<string, number>>Widths set by hand (px).
pinned?Readonly<Record<string, "start" | "end" | null>>Pins; null removes the column's own pinned.
hidden?Readonly<Record<string, boolean>>Hidden columns; false removes the column's own hidden.

Row density.

type DataGridDensity = "compact" | "standard" | "comfortable"

A cell change.

NameTypeDescription
rowTThe changed row (before the change).
rowKeyDataGridKeyKey of the row.
keystringThe column's key.
valueunknownNew value.
oldValueunknownOld value.

The component's own texts; to translate into another language.

NameTypeDefaultDescription
emptystring"Kayıt yok"
noResultsstring"Filtreye uyan kayıt yok"
searchstring"Tabloda ara…"
columnsstring"Sütunlar"
densitystring"Yoğunluk"
compactstring"Sıkışık"
standardstring"Normal"
comfortablestring"Geniş"
exportstring"CSV indir"
sortAscstring"Artan sırala"
sortDescstring"Azalan sırala"
clearSortstring"Sıralamayı kaldır"
filterstring"Filtrele…"
clearFilterstring"Filtreyi kaldır"
clearAllFiltersstring"Tüm filtreleri kaldır"
pinStartstring"Başa sabitle"
pinEndstring"Sona sabitle"
unpinstring"Sabitlemeyi kaldır"
groupBystring"Bu sütuna göre grupla"
ungroupstring"Gruplamayı kaldır"
autosizestring"Genişliği içeriğe sığdır"
autosizeAllstring"Tüm sütunları sığdır"
hidestring"Sütunu gizle"
showAllstring"Tümünü göster"
resetstring"Sıfırla"
copystring"Kopyala"
copyWithHeadersstring"Başlıklarla kopyala"
pastestring"Yapıştır"
clearstring"Hücreleri temizle"
editstring"Düzenle"
undostring"Geri al"
redostring"Yinele"
selectAllstring"Tümünü seç"
selectRowstring"Satırı seç"
expandstring"Aç"
collapsestring"Kapat"
expandAllstring"Tümünü aç"
collapseAllstring"Tümünü kapat"
groupBarHintstring"Gruplamak için sütun başlığını buraya sürükleyin"
rowsstring"kayıt"
selectedstring"seçili"
operatorstring"Koşul"
valuestring"Değer"
fromstring"En az"
tostring"En çok"
yesstring"Evet"
nostring"Hayır"
totalstring"Toplam"
columnMenustring"Sütun menüsü"
dragRowstring"Satırı taşı"
loadingstring"Yükleniyor"
savingstring"Kaydediliyor"
sortedAscstring"artan sıralandı"
sortedDescstring"azalan sıralandı"
copiedstring"hücre kopyalandı"
pastedstring"hücre yapıştırıldı"
pasteSkippedstring"hücre geçersiz olduğu için atlandı"
sharestring"Dışa aktar"Export (React Native: share sheet).
moveLeftstring"Sola taşı"Moves the column one to the left.
moveRightstring"Sağa taşı"
moveUpstring"Yukarı taşı"Moves the row one up (screen reader).
moveDownstring"Aşağı taşı"
addSortstring"Sıralamaya ekle"Adds the column to the sort in multi-sort.
applystring"Uygula"Confirm button of the filter panel.
detailsstring"Ayrıntı"Row detail.
invalidValuestring"Geçersiz değer"When an edited cell's value can't be read for its column type.
exportFileNamestring"tablo"Default name of the exported CSV file (without extension).
operatorsRecord<DataGridFilterOperator, string>Names of the filter operators.
aggregatesRecord<DataGridAggregateName, string>Names of the aggregation functions.

DataGridApi

interface

Functions of the DataGrid callable from outside (apiRef).

NameTypeDescription
getVisibleRows() => T[]Visible (filtered, sorted) rows. Expanded tree rows included.
getSelectedRows() => T[]Selected rows.
exportCsv(options?: { fileName?: string; rows?: "all" | "selected"; }) => voidDownloads a CSV file. rows: "selected" writes only the selected rows, "all" (default) all filtered rows (all pages).
getCsv(options?: { rows?: "all" | "selected"; }) => stringReturns the CSV text (without downloading).
scrollToRow(key: DataGridKey) => voidScrolls a row into view and focuses it.
startEdit(key: DataGridKey, column: string) => voidOpens a cell for editing.
resetColumns() => voidResets the column layout (order, width, pinning, visibility).
expandAll() => voidExpands all groups and tree nodes.
collapseAll() => voidCollapses all groups and tree nodes.