Skip to content

Commit ba10247

Browse files
committed
fix searching in tables that are not sorted
1 parent 009d9bd commit ba10247

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

examples/official-site/sqlpage/migrations/01_documentation.sql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,19 @@ INSERT INTO example(component, description, properties) VALUES
368368
'{"Forename": "Ophir", "Surname": "Lojkine", "Pseudonym": "lovasoa"},' ||
369369
'{"Forename": "Linus", "Surname": "Torvalds", "Pseudonym": "torvalds"}]')),
370370
('table', 'A table that uses markdown to display links',
371-
json('[{"component":"table", "markdown": "Documentation", "icon": "icon"}, '||
371+
json('[{"component":"table", "markdown": "Documentation", "icon": "icon", "sort": true, "search": true}, '||
372372
'{"icon": "table", "name": "Table", "description": "Displays SQL results as a searchable table.", "Documentation": "[docs](documentation.sql?component=table)", "_sqlpage_color": "red"},
373373
{"icon": "timeline", "name": "Chart", "description": "Show graphs based on numeric data.", "Documentation": "[docs](documentation.sql?component=chart)"}
374-
]'));
374+
]')),
375+
(
376+
'table',
377+
'A table with dashes',
378+
json(
379+
'[{"component":"table", "search": true}, ' ||
380+
'{"id": 31456, "part_no": "MIC-ROCC-F-23-206-C"}
381+
]'
382+
)
383+
);
375384

376385

377386
INSERT INTO component(name, icon, description) VALUES

sqlpage/sqlpage.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ function sqlpage_table(){
144144
// Tables
145145
for (const r of document.getElementsByClassName("data-list")) {
146146
new List(r, {
147-
valueNames: [...r.getElementsByClassName("sort")]
148-
.map(t => t.dataset.sort),
147+
valueNames: [...r.getElementsByTagName("th")].map(t => t.textContent),
149148
indexAsync: true
150149
});
151150
}

0 commit comments

Comments
 (0)