Skip to content

Commit 37075d3

Browse files
authored
Merge pull request #7 from piever/pv/size
Allow custom height and width in pixels, viewport or parent units
2 parents 210814e + 22a611e commit 37075d3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/TableView.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ function __init__()
1515
end
1616
end
1717

18-
function showtable(table; dark = false, height = 500)
18+
to_css_size(s::AbstractString) = s
19+
to_css_size(s::Real) = "$(s)px"
20+
21+
function showtable(table; dark = false, height = 500, width = "100%")
1922
if !Tables.istable(typeof(table))
2023
throw(ArgumentError("Argument is not a table."))
2124
end
@@ -47,8 +50,8 @@ function showtable(table; dark = false, height = 500)
4750

4851
id = string("grid-", string(uuid1())[1:8])
4952
w.dom = dom"div"(className = "ag-theme-balham$(dark ? "-dark" : "")",
50-
style = Dict("width" => "100%",
51-
"height" => "$(height)px"),
53+
style = Dict("width" => to_css_size(width),
54+
"height" => to_css_size(height)),
5255
id = id)
5356

5457
tablelength === nothing || tablelength > 10_000 ? _showtable_async!(w, names, types, rows, coldefs, tablelength, dark, id) :

0 commit comments

Comments
 (0)