I have an existing HTML table. I'd like a thin JS library to add simple search and sorting. GridJS looks promising, but I don't understand the docs for loading from HTML. For example, I'm unable to use the useRef
function. Even the first line of code in the example fails for me:
>>> gridjs.useRef(null)
Uncaught TypeError: Bt is undefined
Preact 3
<anonymous> debugger eval code:1
Here is a minimal example:
<html>
<head>
<link href='https://unpkg.com/gridjs/dist/theme/mermaid.min.css' rel='stylesheet'>
<script src="https://cdn.jsdelivr.net/npm/gridjs/dist/gridjs.umd.js"></script>
</head>
<body>
<table id='table'>
<tr>
<td>Foo</td>
<td>Bar</td>
<td>Baz</td>
</tr>
</table>
<script>
window.onload = function() {
var node = document.getElementById('table');
new gridjs.Grid({'from': node});
}
</script>
</body>
</html>
I get the error
Uncaught TypeError: t.querySelector(...) is null
fromHTMLTable header.ts:288
fromUserConfig header.ts:256
fromUserConfig config.ts:179
update config.ts:146
e grid.ts:15
onload example.html:17
EventHandlerNonNull* example.html:15