Platform
Resources
Pricing
Sign in
Get started
Simon Willison
Workspace
Fork
Published
By
Simon Willison
Edited
Jun 10, 2020
1 fork
1 star
Insert cell
md
`# Grid.js with Datasette`
Insert cell
viewof
form_input
=
form
(
html
`<form>
<div><label>Database URL <input style="padding: 5px; font-size: 14px; width: 30em" name="url" type="text" value="${
initial_url
}"></label></div>
</form>`
)
Insert cell
html
`You can share a <a href="/@simonw/grid-js-with-datasette?url=${
encodeURIComponent
(
form_input
.
url
)
}">link to this page</a>`
Insert cell
data
=
await
fetch
(
form_input
.
url
)
.
then
(
r
=>
r
.
json
(
)
)
;
Insert cell
{
var
g
=
new
gridjs
.
Grid
(
{
columns
:
data
.
columns
,
data
:
data
.
rows
}
)
;
var
el
=
document
.
createElement
(
'div'
)
;
g
.
render
(
el
)
;
return
el
;
}
Insert cell
html
`<link rel="stylesheet" href="https://unpkg.com/gridjs/dist/theme/mermaid.min.css">`
Insert cell
Insert cell
import
{
form
}
from
"@mbostock/form-input"
Insert cell
initial_url
=
decodeURIComponent
(
location
.
href
.
split
(
"?url="
)
[
1
]
||
''
)
||
'https://covid-19.datasettes.com/covid/ny_times_us_states.json?state=Arizona'
Insert cell
location
.
href
.
split
(
"?url="
)
[
1
]
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
form_input
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
data
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
gridjs
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
initial_url
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML