Skip to content

Commit d45d52b

Browse files
committed
Keep table settings and core examples in editable files
1 parent 8a22a69 commit d45d52b

10 files changed

Lines changed: 259 additions & 94 deletions

File tree

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
icon: table
3+
category: display-data
4+
summary: Turn query results into a sortable, searchable table.
5+
top:
6+
- name: align_center
7+
type: TEXT
8+
description: Name of a column the contents of which should be center-aligned. This argument can be repeated
9+
multiple times to align multiple columns to the center.
10+
- name: align_right
11+
type: TEXT
12+
description: Name of a column the contents of which should be right-aligned. This argument can be repeated
13+
multiple times to align multiple columns to the right. Introduced in v0.15.0.
14+
- name: border
15+
type: BOOLEAN
16+
description: Whether to draw borders on all sides of the table and cells.
17+
- class
18+
- name: currency
19+
type: TEXT
20+
description: The ISO 4217 currency code (e.g., USD, EUR, GBP, etc.) to use when formatting monetary values.
21+
- name: custom_actions
22+
type: JSON
23+
description: 'If set, a column of custom action buttons will be added to each row. The value of this property
24+
should be a JSON array of objects, each object defining a button with the following properties: `name`
25+
(the text to display on the button), `icon` (the tabler icon name or image link to display on the button),
26+
`link` (the URL to navigate to when the button is clicked, possibly containing the `{id}` placeholder
27+
that will be replaced by the value of the `_sqlpage_id` property for that row), and `tooltip` (optional
28+
text to display when hovering over the button). Added in v0.39.0'
29+
- name: delete_url
30+
type: TEXT
31+
description: If set, a delete button will be added to each row. The value of this property should be a
32+
URL, possibly containing the `{id}` placeholder that will be replaced by the value of the `_sqlpage_id`
33+
property for that row. Clicking the delete button will take the user to that URL. Added in v0.39.0
34+
- name: description
35+
type: TEXT
36+
description: Description of the table contents. Helps users with screen readers to find a table and understand
37+
what it’s about.
38+
- name: edit_url
39+
type: TEXT
40+
description: If set, an edit button will be added to each row. The value of this property should be a URL,
41+
possibly containing the `{id}` placeholder that will be replaced by the value of the `_sqlpage_id` property
42+
for that row. Clicking the edit button will take the user to that URL. Added in v0.39.0
43+
- name: embed
44+
type: TEXT
45+
description: Name of a column whose values are URLs to HTML fragments, such as other SQLPage pages.
46+
Repeat this property to select multiple columns. The browser fetches each nonempty URL with
47+
`_sqlpage_embed=1`, which skips the SQLPage shell, and initializes any components inside the cell.
48+
Use only URLs whose HTML you trust. There is one request per populated cell. Sorting uses the original
49+
URL, and search skips embedded cells.
50+
- name: empty_description
51+
type: TEXT
52+
description: Text to display if the table does not contain any row. Defaults to "no data".
53+
- name: freeze_columns
54+
type: BOOLEAN
55+
description: Whether to freeze the leftmost column of the table.
56+
- name: freeze_footers
57+
type: BOOLEAN
58+
description: Whether to freeze the footer (bottom row) of the table, only works if that row has the `_sqlpage_footer`
59+
property applied to it.
60+
- name: freeze_headers
61+
type: BOOLEAN
62+
description: Whether to freeze the top row of the table.
63+
- name: hover
64+
type: BOOLEAN
65+
description: Whether to enable a hover state on table rows.
66+
- name: icon
67+
type: TEXT
68+
description: Set this to the name of a column whose content should be interpreted as a tabler icon name.
69+
Used to display icons in the table. This argument can be repeated multiple times to intepret multiple
70+
columns as icons. Introduced in v0.8.0.
71+
- id
72+
- name: initial_search_value
73+
type: TEXT
74+
description: Pre-fills the search bar used to filter the table. The user will still be able to edit the
75+
value to display table rows that will initially be filtered out.
76+
- name: markdown
77+
type: TEXT
78+
description: Set this to the name of a column whose content should be interpreted as markdown . Used to
79+
display rich text with links in the table. This argument can be repeated multiple times to intepret multiple
80+
columns as markdown.
81+
- name: money
82+
type: TEXT
83+
description: Name of a numeric column whose values should be displayed as currency amounts, in the currency
84+
defined by the `currency` property. This argument can be repeated multiple times.
85+
- name: monospace
86+
type: TEXT
87+
description: Name of a column the contents of which should be displayed in monospace. This argument can
88+
be repeated multiple times to display multiple columns in monospace. Introduced in v0.32.1.
89+
- name: number_format_digits
90+
type: INTEGER
91+
description: Maximum number of decimal digits to display for numeric values.
92+
- name: number_format_locale
93+
type: TEXT
94+
description: A BCP 47 language tag (e.g. "de-DE", "en-IN") deciding how numbers and monetary values are
95+
formatted. Defaults to the locale of the visitor's browser.
96+
- name: overflow
97+
type: BOOLEAN
98+
description: Whether to to let "wide" tables overflow across the right border and enable browser-based
99+
horizontal scrolling.
100+
- name: raw_numbers
101+
type: TEXT
102+
description: Name of a column whose values are numeric, but should be displayed as raw numbers without
103+
any formatting (no thousands separators, decimal separator is always a dot). This argument can be repeated
104+
multiple times.
105+
- name: search
106+
type: BOOLEAN
107+
description: Add a search bar at the top of the table, letting users easily filter table rows by value.
108+
- name: search_placeholder
109+
type: TEXT
110+
description: Customizes the placeholder text shown in the search input field. Replaces the default "Search..."
111+
with text that better describes what users should search for.
112+
- name: small
113+
type: BOOLEAN
114+
description: Whether to use compact table.
115+
- name: sort
116+
type: BOOLEAN
117+
description: Make the columns clickable to let the user sort by the value contained in the column.
118+
- name: striped_columns
119+
type: BOOLEAN
120+
description: Whether to add zebra-striping to any table column.
121+
- name: striped_rows
122+
type: BOOLEAN
123+
description: Whether to add zebra-striping to any table row.
124+
- name: title
125+
type: TEXT
126+
description: A title displayed above the table.
127+
row:
128+
- name: _sqlpage_actions
129+
type: JSON
130+
description: 'Sets custom action buttons for this specific row in addition to any defined at the table
131+
level, The value of this property should be a JSON array of objects, each object defining a button with
132+
the following properties: `name` (the text to display on the button), `icon` (the tabler icon name or
133+
image link to display on the button), `link` (the URL to navigate to when the button is clicked, possibly
134+
containing the `{id}` placeholder that will be replaced by the value of the `_sqlpage_id` property for
135+
that row), and `tooltip` (optional text to display when hovering over the button). Added in v0.39.0'
136+
- name: _sqlpage_color
137+
type: COLOR
138+
description: Sets the background color of the row. Added in v0.8.0.
139+
- name: _sqlpage_css_class
140+
type: TEXT
141+
description: For advanced users. Sets a css class on the table row. Added in v0.8.0.
142+
- name: _sqlpage_footer
143+
type: BOOLEAN
144+
description: Sets this row as the table footer. It is recommended that this parameter is applied to the
145+
last row. Added in v0.34.0.
146+
- name: _sqlpage_id
147+
type: TEXT
148+
description: Sets the id of the html tabler row element. Allows you to make links targeting a specific
149+
row in a table.
150+
---
151+
152+
A table with optional filtering and sorting.
153+
Unlike most others, this component does not have a fixed set of item properties, any property that is used will be rendered directly as a column in the table.
154+
Tables can contain rich text, including images, links, and icons. Table rows can be styled with a background color, and the table can be made striped, hoverable, and bordered.
155+
156+
Advanced users can apply custom styles to table columns using a CSS class with the same name as the column, and to table rows using the `_sqlpage_css_class` property.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
rows:
3+
- component: table
4+
- a: 1
5+
b: 2
6+
- a: 3
7+
b: 4
8+
---
9+
10+
The most basic table.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
rows:
3+
- component: table
4+
sort: true
5+
search: true
6+
search_placeholder: Filter by name
7+
- First Name: Ophir
8+
Last Name: Lojkine
9+
Pseudonym: lovasoa
10+
- First Name: Linus
11+
Last Name: Torvalds
12+
Pseudonym: torvalds
13+
---
14+
15+
A table of users with filtering and sorting.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
rows:
3+
- component: table
4+
markdown: Name
5+
icon: icon
6+
search: true
7+
- icon: table
8+
name: '[Table](?component=table)'
9+
description: Displays SQL results as a searchable table.
10+
_sqlpage_color: red
11+
- icon: timeline
12+
name: '[Chart](?component=chart)'
13+
description: Show graphs based on numeric data.
14+
---
15+
16+
A table that uses markdown to display links
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
rows:
3+
- component: table
4+
embed: Chart
5+
- Starting number: 7
6+
Chart: /examples/chart.sql?n=7&color=blue
7+
- Starting number: 13
8+
Chart: /examples/chart.sql?n=13&color=green
9+
---
10+
11+
A table that embeds a chart from another SQLPage file in each row.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
rows:
3+
- component: table
4+
sort: true
5+
- Person: Rudolph Lingens
6+
Height: 190
7+
- Person: Jane Doe
8+
Height: 150
9+
- Person: John Doe
10+
Height: 200
11+
- _sqlpage_footer: true
12+
_sqlpage_color: green
13+
Person: Average
14+
Height: 180
15+
---
16+
17+
A sortable table with a colored footer showing the average value of its entries.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
rows:
3+
- component: table
4+
sort: true
5+
align_right:
6+
- Price
7+
- Amount in stock
8+
align_center:
9+
- part_no
10+
raw_numbers:
11+
- id
12+
currency: USD
13+
money:
14+
- Price
15+
- id: 31456
16+
part_no: SQL-TABLE-856-G
17+
Price: 12
18+
Amount in stock: 5
19+
- id: 996
20+
part_no: SQL-FORMS-86-M
21+
Price: 1
22+
Amount in stock: 1234
23+
- id: 131456
24+
part_no: SQL-CARDS-56-K
25+
Price: 127
26+
Amount in stock: 98
27+
---
28+
29+
A table with column sorting. Sorting sorts numbers in numeric order, and strings in alphabetical order.
30+
31+
Numbers can be displayed
32+
- as raw digits without formatting using the `raw_numbers` property,
33+
- as currency using the `money` property to define columns that contain monetary values and `currency` to define the currency,
34+
- as numbers with a fixed maximum number of decimal digits using the `number_format_digits` property.

0 commit comments

Comments
 (0)