Skip to main content

Events

React to taps and long presses on rows and cells.

Basic usage​

events.tsx
import { DataGrid } from 'expo-flash-datagrid';

import { userColumns, users, type User } from './data';

export function EventsScreen() {
return (
<DataGrid<User>
mode="client"
rows={users}
columns={userColumns}
onRowPress={(row) => console.log('press', row.id)}
onRowLongPress={(row) => console.log('long press', row.id)}
onRowLongPressDetails={({ rowId, position }) =>
console.log(rowId, position.pageX, position.pageY)
}
onCellPress={({ row, column }) => console.log(column.field, row.id)}
onCellLongPress={({ row, column }) =>
console.log(column.field, row.id)
}
style={{ flex: 1 }}
/>
);
}

Options​

PropTypeDescription
onRowPress(row) => voidA row was tapped outside selection.
onRowLongPress(row) => voidA row was long-pressed.
onRowLongPressDetails(params: RowLongPressParams) => voidLong press, with row, rowId, and position.
onCellPress(params: CellEventParams) => voidA cell was tapped. Receives row and column.
onCellLongPress(params: CellEventParams) => voidA cell was long-pressed.

Order​

A cell tap calls onCellPress, then runs the row press. While rows are selectable, a tap toggles selection instead of calling onRowPress.

Client vs server​

Events behave the same in both modes.