|
1 | 1 | module TableView
|
2 | 2 |
|
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 |
4 | 38 |
|
5 | 39 | end # module
|
0 commit comments