Actions column
A column with type: 'actions' puts the actions on the row, so they don't depend on a long press.
Basic usage
actions-column.tsx
import { MaterialIcons } from '@expo/vector-icons';
import {
DataGrid,
type ColumnDef,
type RowActionMenuIconProps,
} from 'expo-flash-datagrid';
import { users, type User } from './data';
function MoreIcon({ color, size }: RowActionMenuIconProps) {
return <MaterialIcons name="more-horiz" color={color} size={size} />;
}
const columns: ColumnDef<User>[] = [
{ field: 'name', headerName: 'Name', flex: 1, minWidth: 160 },
{
field: 'actions',
headerName: 'Actions',
type: 'actions',
width: 132,
align: 'center',
headerAlign: 'center',
actionTrigger: { display: 'both', icon: MoreIcon, label: 'Actions' },
actions: ({ rowId }) => [
{
key: 'open',
label: 'Open',
onPress: () => console.log('open', rowId),
},
{
key: 'share',
label: 'Share',
onPress: () => console.log('share', rowId),
},
],
},
];
export function ActionsColumnScreen() {
return (
<DataGrid<User>
mode="client"
rows={users}
columns={columns}
style={{ flex: 1 }}
/>
);
}
Options
| Field | Type | Description |
|---|---|---|
type | 'actions' | Marks the column as actions. It is excluded from sort, filter, and search. |
actions | GridRowActionsSource | Items, or a function returning them. |
actionTrigger | GridActionCellTrigger | The cell's icon, label, and display. |
Display order
The cell uses actionTrigger.display first, then the item's displayInCell. Without either, it shows both when it has an icon and a label, otherwise whichever exists.
Client vs server
Actions columns behave the same in both modes.