Row actions overview
Defining per-row actions with TableRowAction
Row actions are buttons on each row — View, Edit, Archive, Toggle active, etc. You define them in PHP; the frontend renders buttons from the rowActions object in structure JSON.
When to use row vs bulk actions
| Row action | Bulk action |
|---|---|
| Affects one record | Affects selection or full filtered set |
| Archive one order | Export 50 selected orders |
| View details | Email report of all filtered rows |
Anatomy of a row action
use Storageitsolutions\ApisTables\Actions\RowActions\TableRowAction;
use Storageitsolutions\ApisTables\Enums\RowActionsTypes;
use Storageitsolutions\ApisTables\Enums\ActionOnSuccessDo;
protected function setRowActions(): array
{
return array_merge(parent::setRowActions(), [
'archive' => new TableRowAction(
tableName: self::TABLENAME,
key: 'archive',
label: 'Archive',
action_type: RowActionsTypes::ROW_ACT_TYPE_NORMAL,
executeCallBack: 'archiveRecord',
isApplicableCallback: 'canArchive',
need_confirmation: true,
),
]);
}| Parameter | Purpose |
|---|---|
key | URL segment — slugified to archive |
label | Button text in UI |
action_type | How frontend behaves — Action types |
executeCallBack | Method name on your table class |
isApplicableCallback | Hide button when returns false |
need_confirmation | Show confirm dialog before POST |
Implement the callback
use Illuminate\Http\Request;
public function archiveRecord(int|string $id, Request $request): array
{
$order = $this->model::findOrFail($id);
$this->authorize('archive', $order); // optional policy
$order->update(['status' => 'archived']);
return [
'success' => true,
'message' => 'Order archived',
];
}Return shape should include success: true or success: false with errors array.
Built-in: show_details
Every table inherits show_details unless you replace setRowActions() entirely without merging parent. It calls getRowDetails and opens a modal (onSuccess: DisplayOnModal).
onSuccess — what frontend does after
ActionOnSuccessDo | Frontend behavior |
|---|---|
refetchRow | Refresh single row (row-refetch) |
refetchData | Reload full table (query-table) |
DisplayOnModal | Show response data in modal |
no_action | No automatic refresh |
Set on the action object:
$action = new TableRowAction(/* ... */);
$action->setOnSuccess(ActionOnSuccessDo::ROWACTION_SUCCESS_DATAFETCH);Conditional visibility
public function canArchive($item): bool
{
return $item->status !== 'archived';
}Pass 'canArchive' as isApplicableCallback. Returning false removes the button for that row only.
Row bulk (multi-select same action)
Enable running a row action on multiple selected IDs:
$action->setApplicableAsBulk(true);Client calls row-bulk-table-action/{table}/{action} with selected_ids: [1,2,3].
Common mistakes
| Mistake | Result |
|---|---|
| Forgot to merge parent actions | Lose show_details |
| Callback method typo | 500 or action not defined |
| Key mismatch in URL | Action is not defined |
No success in return | Frontend error handling breaks |