Action Definitions
Actions are operations that can be performed on table data. There are 3 types of actions: bulk actions, table actions, and row actions.
- Bulk Actions: Actions that can be performed on multiple selected rows. Selected rows are passed to the action callback, allowing for operations on multiple items at once.
- Table Actions: Actions that can be performed on the table as a whole. It doesn't have an access to the row data, so it's typically used for operations that affect the entire table, e.g. cleaning the table data.
- Row Actions: Actions that can be performed on individual rows. These actions are accessible via a per-row menu and receive the row's data in the action callback.
Each action callback returns an ActionHandlerResult object, below you can see its definition:
ActionHandlerResult
Bases: TypedDict
Represents the result of an action handler.
| ATTRIBUTE | DESCRIPTION |
|---|---|
success |
Indicates whether the action was successful.
TYPE:
|
error |
(Optional) Error message if the action failed.
TYPE:
|
redirect |
(Optional) URL to redirect to after the action.
TYPE:
|
message |
(Optional) Informational message about the action result.
TYPE:
|
Source code in ckanext/tables/types.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
BulkActionDefinition
dataclass
Defines an action that can be performed on multiple rows.
| ATTRIBUTE | DESCRIPTION |
|---|---|
action |
Unique identifier for the action.
TYPE:
|
label |
Display label for the action.
TYPE:
|
callback |
Function to be called when the action is triggered.
TYPE:
|
icon |
(Optional) Icon class for the action.
TYPE:
|
with_confirmation |
(Optional) Whether to show a confirmation dialog before executing the action. Defaults to True, since a bulk action affects every selected row.
TYPE:
|
Source code in ckanext/tables/table.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
TableActionDefinition
dataclass
Defines an action that can be performed on the table itself.
| ATTRIBUTE | DESCRIPTION |
|---|---|
action |
Unique identifier for the action.
TYPE:
|
label |
Display label for the action.
TYPE:
|
callback |
Function to be called when the action is triggered.
TYPE:
|
icon |
(Optional) Icon class for the action.
TYPE:
|
with_confirmation |
(Optional) Whether to show a confirmation dialog before executing the action. Defaults to True; set to False for a non-destructive actions.
TYPE:
|
Source code in ckanext/tables/table.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | |
RowActionDefinition
dataclass
Defines an action that can be performed on a row.
| ATTRIBUTE | DESCRIPTION |
|---|---|
action |
Unique identifier for the action.
TYPE:
|
label |
Display label for the action.
TYPE:
|
callback |
Function to be called when the action is triggered.
TYPE:
|
icon |
(Optional) Icon class for the action.
TYPE:
|
with_confirmation |
(Optional) Whether to show a confirmation dialog before executing the action.
TYPE:
|
Source code in ckanext/tables/table.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |