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
| Prop | Type | Description |
|---|---|---|
onRowPress | (row) => void | A row was tapped outside selection. |
onRowLongPress | (row) => void | A row was long-pressed. |
onRowLongPressDetails | (params: RowLongPressParams) => void | Long press, with row, rowId, and position. |
onCellPress | (params: CellEventParams) => void | A cell was tapped. Receives row and column. |
onCellLongPress | (params: CellEventParams) => void | A 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.