You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/official-site/sqlpage/migrations/01_documentation.sql
+45-90Lines changed: 45 additions & 90 deletions
Original file line number
Diff line number
Diff line change
@@ -1001,88 +1001,66 @@ This will generate a table with the stores in the first column, and the items in
1001
1001
),
1002
1002
(
1003
1003
'table',
1004
-
'# Using row based custom actions in a table
1004
+
'## Using Action Buttons in a table.
1005
1005
1006
-
The table has a column of buttons, each button defined by the `_sqlpage_actions` column at the table level, and by the `_sqlpage_actions` property at the row level.
1006
+
### Preset Actions: `edit_url` & `delete_url`
1007
+
Since edit and delete are common actions, the `table` component has dedicated `edit_url` and `delete_url` properties to add buttons for these actions.
1008
+
The value of these properties should be a URL, containing the `{id}` placeholder that will be replaced by the value of the `_sqlpage_id` property for that row.
1007
1009
1008
-
```sql
1009
-
SELECT
1010
-
name, vendor, product_number, facility_name,
1011
-
lot_number, status, date_of_expiration,
1012
-
--Use the unique identifier of the row as the _sqlpage_id property
1013
-
standard_id AS _sqlpage_id,
1014
-
--Build an array of objects, each object defining a button with the following properties: name, icon, link, tooltip
1015
-
json_array(--SQLite specific, refer to your database documentation for the equivalent JSON functions
1016
-
--The {id} placeholder in the link property will be replaced by the value of the _sqlpage_id property for that row.
1017
-
json_object(''name'', ''history'', ''tooltip'', ''View Standard History'', ''link'', ''./history.sql?standard_id={id}'', ''icon'', ''history''),
-- Include an action with no link or icon as a placeholder to keep the buttons aligned and make sure the header is correct.
1041
-
WHEN status = ''Discarded'' THEN json_object(''name'',''Action'')
1042
-
1043
-
ELSE json_object(''name'',''Action'')
1044
-
END
1045
-
)
1046
-
AS _sqlpage_actions
1047
-
FROM standard;
1048
-
1049
-
```
1010
+
### Column with fixed action buttons
1050
1011
1012
+
You may want to add custom action buttons to your table rows, for instance to view details, download a file, or perform a custom operation.
1013
+
For this, the `table` component has a `custom_actions` property that lets you define a column of buttons, each button defined by a name, an icon, a link, and an optional tooltip.
1051
1014
1052
-
'
1015
+
### Column with variable action buttons
1016
+
1017
+
The `table` component also supports the row level `_sqlpage_actions` column in your data table.
1018
+
This is helpful if you want a more complex logic, for instance to disable a button on some rows, or to change the link or icon based on the row data.
1019
+
1020
+
> WARNING!
1021
+
> If the number of array items in `_sqlpage_actions` is not consistent across all rows, the table may not render correctly.
1022
+
> You can leave blank spaces by including an object with only the `name` property.
1023
+
1024
+
The table has a column of buttons, each button defined by the `_sqlpage_actions` column at the table level, and by the `_sqlpage_actions` property at the row level.
Each button is defined by the following properties:
1027
+
* `name`: sets the column header and the tooltip if no tooltip is provided,
1028
+
* `tooltip`: text to display when hovering over the button,
1029
+
* `link`: the URL to navigate to when the button is clicked, possibly containing the {id} placeholder that will be replaced by the value of the `_sqlpage_id` property for that row,
1030
+
* `icon`: the tabler icon name or image link to display on the button
0 commit comments