Skip to main content

Row actions

rowActions opens a menu for a row, by default on long press. Pass an array, or a function to build items per row.

Basic usage​

row-actions.tsx
import { MaterialIcons } from '@expo/vector-icons';
import {
DataGrid,
type GridRowActionsSource,
type RowActionMenuIconProps,
} from 'expo-flash-datagrid';

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

function EditIcon({ color, size }: RowActionMenuIconProps) {
return <MaterialIcons name="edit" color={color} size={size} />;
}

function DeleteIcon({ color, size }: RowActionMenuIconProps) {
return <MaterialIcons name="delete" color={color} size={size} />;
}

const rowActions: GridRowActionsSource<User> = ({ row }) => [
{
key: 'edit',
label: 'Edit',
icon: EditIcon,
disabled: !row.active,
onPress: ({ rowId }) => console.log('edit', rowId),
},
{
key: 'delete',
label: 'Delete',
icon: DeleteIcon,
destructive: true,
onPress: ({ rowId }) => console.log('delete', rowId),
},
];

export function RowActionsScreen() {
return (
<DataGrid<User>
mode="client"
rows={users}
columns={userColumns}
rowActions={rowActions}
onRowActionMenuOpen={({ rowId, actions }) =>
console.log(rowId, actions.length)
}
style={{ flex: 1 }}
/>
);
}

Options​

PropTypeDefaultDescription
rowActionsGridRowActionsSourceNoneItems, or a function returning them.
rowActionMenuTrigger'none' | 'longPress''longPress' when rowActions is setSet 'none' to keep long press for selection.
onRowActionMenuOpen(params: RowActionMenuOpenParams) => voidNoneCalled when the menu opens.

GridRowActionItem​

FieldTypeDescription
keystringUnique key.
labelstringMenu text.
iconGridRowActionIconA node, or a function receiving { color, size }.
cellLabelstringText used in an actions column.
displayInCell'icon' | 'label' | 'both'How an actions column shows it.
disabledbooleanShows the item as unavailable.
destructivebooleanStyles the item as dangerous.
onPress(params: RowLongPressParams) => voidReceives row, rowId, and position.

The menu does not open when the source returns an empty list.

Client vs server​

Row actions work the same in both modes. After a change, refresh rows or refetch.