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
#Added support for action buttons in the table component template.
* A default edit and delete button can be included by specifying an "edit_url" or "delete_url"
* Custom Column based action buttons can be added in the table header using json object array in the custom_actions column.
* Custom action buttons can be defined on the row level by specifying _sqlpage_actions.
Copy file name to clipboardExpand all lines: examples/official-site/sqlpage/migrations/01_documentation.sql
+167-1Lines changed: 167 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -810,11 +810,15 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
810
810
('money', 'Name of a numeric column whose values should be displayed as currency amounts, in the currency defined by the `currency` property. This argument can be repeated multiple times.', 'TEXT', TRUE, TRUE),
811
811
('currency', 'The ISO 4217 currency code (e.g., USD, EUR, GBP, etc.) to use when formatting monetary values.', 'TEXT', TRUE, TRUE),
812
812
('number_format_digits', 'Maximum number of decimal digits to display for numeric values.', 'INTEGER', TRUE, TRUE),
813
+
('edit_url', 'If set, an edit button will be added to each row. The value of this property should be a URL, possibly containing the `{id}` placeholder that will be replaced by the value of the `_sqlpage_id` property for that row. Clicking the edit button will take the user to that URL.', 'TEXT', TRUE, TRUE),
814
+
('delete_url', 'If set, a delete button will be added to each row. The value of this property should be a URL, possibly containing the `{id}` placeholder that will be replaced by the value of the `_sqlpage_id` property for that row. Clicking the delete button will take the user to that URL.', 'TEXT', TRUE, TRUE),
815
+
('custom_actions', 'If set, a column of custom action buttons will be added to each row. The value of this property should be a JSON array of objects, each object defining a button with the following properties: `name` (the text to display on the button), `icon` (the tabler icon name or image link to display on the button), `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), and `tooltip` (optional text to display when hovering over the button).', 'JSON', TRUE, TRUE),
813
816
-- row level
814
817
('_sqlpage_css_class', 'For advanced users. Sets a css class on the table row. Added in v0.8.0.', 'TEXT', FALSE, TRUE),
815
818
('_sqlpage_color', 'Sets the background color of the row. Added in v0.8.0.', 'COLOR', FALSE, TRUE),
816
819
('_sqlpage_footer', 'Sets this row as the table footer. It is recommended that this parameter is applied to the last row. Added in v0.34.0.', 'BOOLEAN', FALSE, TRUE),
817
-
('_sqlpage_id', 'Sets the id of the html tabler row element. Allows you to make links targeting a specific row in a table.', 'TEXT', FALSE, TRUE)
820
+
('_sqlpage_id', 'Sets the id of the html tabler row element. Allows you to make links targeting a specific row in a table.', 'TEXT', FALSE, TRUE),
821
+
('_sqlpage_actions', 'Sets custom action buttons for this specific row in addition to any defined at the table level, The value of this property should be a JSON array of objects, each object defining a button with the following properties: `name` (the text to display on the button), `icon` (the tabler icon name or image link to display on the button), `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), and `tooltip` (optional text to display when hovering over the button).', 'JSON', FALSE, TRUE)
818
822
) x;
819
823
820
824
INSERT INTO example(component, description, properties) VALUES
@@ -994,9 +998,171 @@ GROUP BY
994
998
This will generate a table with the stores in the first column, and the items in the following columns, with the quantity sold in each store for each item.
995
999
996
1000
', NULL
1001
+
),
1002
+
(
1003
+
'table',
1004
+
'# Using row based custom actions in a table
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.
1007
+
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''),
0 commit comments