@@ -52,13 +52,20 @@ Return a `WebIO.Scope` that displays the provided `table`.
52
52
53
53
Optional arguments:
54
54
- `dark`: Switch to a dark theme.
55
+ - `title`: Displayed above the table if non-empty;
55
56
- `height`/`width`: CSS attributes specifying the output height and with.
56
57
- `cell_changed`: Either `nothing` or a function that takes a single argument with the fields
57
58
`"new"`, `"old"`, `"row"`, and `"col"`. This function is called whenever the
58
59
user edits a table field. Note that all values will be strings, so you need to
59
60
do the necessary conversions yourself.
60
61
"""
61
- function showtable (table, options:: Dict{Symbol, Any} = Dict {Symbol, Any} (); dark = false , height = :auto , width = " 100%" , cell_changed = nothing )
62
+ function showtable (table, options:: Dict{Symbol, Any} = Dict {Symbol, Any} ();
63
+ dark:: Bool = false ,
64
+ title:: String = " " ,
65
+ height = :auto ,
66
+ width = " 100%" ,
67
+ cell_changed = nothing
68
+ )
62
69
rows = Tables. rows (table)
63
70
tablelength = Base. IteratorSize (rows) == Base. HasLength () ? length (rows) : nothing
64
71
@@ -148,10 +155,23 @@ function showtable(table, options::Dict{Symbol, Any} = Dict{Symbol, Any}(); dark
148
155
end
149
156
150
157
id = string (" grid-" , string (uuid1 ())[1 : 8 ])
151
- w. dom = dom " div" (className = " ag-theme-balham$(dark ? " -dark" : " " ) " ,
158
+ w. dom = dom " div" (
159
+ dom " div" (
160
+ title,
161
+ style = Dict (
162
+ " background-color" => dark ? " #1c1f20" : " #F5F7F7" ,
163
+ " color" => dark ? " #F5F7F7" : " #1c1f20" ,
164
+ " height" => isempty (title) ? " 0" : " 18px" ,
165
+ " padding" => isempty (title) ? " 0" : " 5px" ,
166
+ " font-family" => """ -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif"""
167
+ )
168
+ ),
169
+ dom " div" (className = " ag-theme-balham$(dark ? " -dark" : " " ) " ,
152
170
style = Dict (" width" => to_css_size (width),
153
171
" height" => to_css_size (height)),
154
- id = id)
172
+ id = id
173
+ )
174
+ )
155
175
156
176
showfun = async ? _showtable_async! : _showtable_sync!
157
177
0 commit comments