Skip to content

Commit 26ec44a

Browse files
author
Shashi Gowda
committed
allow column options to be passed in by column name
1 parent 9852b95 commit 26ec44a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/TableView.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module TableView
33
using WebIO
44
using IndexedTables
55

6-
function showtable(t; rows=1:100, kwargs...)
6+
function showtable(t::IndexedTable; rows=1:100, colopts=Dict(), kwargs...)
77
w = Widget(dependencies=["https://cdnjs.cloudflare.com/ajax/libs/handsontable/0.34.0/handsontable.full.js",
88
"https://cdnjs.cloudflare.com/ajax/libs/handsontable/0.34.0/handsontable.full.css"])
99
data = Observable{Any}(w, "data", [])
@@ -18,6 +18,8 @@ function showtable(t; rows=1:100, kwargs...)
1818

1919
subt = IndexedTable(ks, vs)
2020

21+
columns = [merge(Dict(:data=>n), get(colopts, n, Dict())) for n in vcat(fieldnames(eltype(ks)), fieldnames(eltype(t)))]
22+
2123
headers = [fieldnames(eltype(keys(t))); fieldnames(eltype(t));]
2224
options = Dict(
2325
:data => IndexedTables.rows(subt),
@@ -27,6 +29,7 @@ function showtable(t; rows=1:100, kwargs...)
2729
:modifyRowHeight => @js(h -> h > 60 ? 50 : h),
2830
:manualColumnResize => true,
2931
:manualRowResize => true,
32+
:columns => columns,
3033
:width => 800,
3134
:height => 400,
3235
)

0 commit comments

Comments
 (0)