Skip to content

Commit 13ecf41

Browse files
author
Shashi Gowda
committed
first commit
1 parent 3579f60 commit 13ecf41

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

REQUIRE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
julia 0.6
2+
WebIO
3+
IndexedTables

src/TableView.jl

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
module TableView
22

3-
# package code goes here
3+
using WebIO
4+
using IndexedTables
5+
6+
function showtable(t; rows=1:100)
7+
w = Widget(dependencies=["https://cdnjs.cloudflare.com/ajax/libs/handsontable/0.34.0/handsontable.full.js",
8+
"https://cdnjs.cloudflare.com/ajax/libs/handsontable/0.34.0/handsontable.full.css"])
9+
data = Observable{Any}(w, "data", [])
10+
11+
subt = IndexedTable(keys(t)[rows], values(t)[rows])
12+
13+
headers = [fieldnames(eltype(keys(t))); fieldnames(eltype(t));]
14+
options = Dict(
15+
:data => IndexedTables.rows(subt),
16+
:colHeaders => headers,
17+
:fixedColumnsLeft => ndims(t),
18+
:modifyColWidth => @js(w -> w > 300 ? 300 : w),
19+
:modifyRowHeight => @js(h -> h > 60 ? 50 : h),
20+
:manualColumnResize => true,
21+
:manualRowResize => true,
22+
:width =>800,
23+
:height =>400
24+
)
25+
handler = @js function (Handsontable)
26+
@var sizefix = document.createElement("style");
27+
sizefix.textContent = """
28+
.htCore td {
29+
white-space:nowrap
30+
}
31+
"""
32+
this.dom.appendChild(sizefix)
33+
this.hot = @new Handsontable(this.dom, $options);
34+
end
35+
ondependencies(w, handler)
36+
w()
37+
end
438

539
end # module

0 commit comments

Comments
 (0)