Context Menus
Grid body-cell context menus are built from FdcMenuEntry objects. A grid-level builder can provide common commands, while an individual column can override it with its own menuBuilder.
Add a grid-level menu
FdcGrid(
dataSet: customers,
menuBuilder: (context) => [
FdcMenuAction(
text: 'Open customer',
onPressed: () => openCustomer(context.recordId),
),
const FdcMenuSeparator(),
FdcMenuAction(
text: 'Copy company name',
onPressed: () => copyText('${context.value ?? ''}'),
),
],
)
The FdcGridMenuContext provides the dataset, row and column context, current value, row-selection state, editing state, and record commands that are valid for the current cell.
Override a specific column
FdcTextColumn(
fieldName: 'email',
label: 'Email',
menuBuilder: (context) => [
FdcMenuAction(
text: 'Compose email',
onPressed: () => composeEmail('${context.value ?? ''}'),
),
],
)
A column menu builder takes precedence for cells in that column.
Menu entry types
The shared menu model includes:
FdcMenuActionfor immediate commands;FdcMenuCheckActionfor toggle-style commands;FdcMenuTitlefor non-interactive group captions;FdcMenuSeparatorfor visual grouping;FdcSubMenufor nested commands;FdcMenuWidgetEntryfor custom widget content.
Keep context-menu actions focused on the current cell or record. Long-running business workflows should usually hand off to an application service rather than placing persistence logic directly in the builder.
Range-selection context menu
Range Selection has its own copy/paste context-menu behavior. Configure it through FdcGridRangeSelection rather than the body-cell menuBuilder.