Skip to content

Commit dae9827

Browse files
authored
Merge pull request #61 from baumgold/auto_resize
Fix autoSizeColumns and reduce unnecessary async usage
2 parents 990fbda + 6e732f6 commit dae9827

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "TableView"
22
uuid = "40c74d1a-b44c-5b06-a7c1-6cbea58ea978"
3-
version = "0.6.2"
3+
version = "0.6.3"
44

55
[deps]
66
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

src/TableView.jl

+6-7
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ function showtable(table, options::Dict{Symbol, Any} = Dict{Symbol, Any}();
6868
cell_changed = nothing
6969
)
7070
rows = Tables.rows(table)
71-
tablelength = Base.IteratorSize(rows) == Base.HasLength() ? length(rows) : nothing
71+
it_sz = Base.IteratorSize(rows)
72+
has_len = it_sz isa Base.HasLength || it_sz isa Base.HasShape
73+
tablelength = has_len ? length(rows) : nothing
7274

7375
if height === :auto
7476
height = 500
@@ -90,6 +92,7 @@ function showtable(table, options::Dict{Symbol, Any} = Dict{Symbol, Any}();
9092
push!(names, nm)
9193
push!(types, typeof(getproperty(row, nm)))
9294
end
95+
schema = Tables.Schema(names, types)
9396
else
9497
# no schema and no rows
9598
end
@@ -202,9 +205,7 @@ function _showtable_sync!(w, schema, names, types, rows, coldefs, tablelength, i
202205
"rowNumberRenderer" => RowNumberRenderer
203206
)
204207
this.table = @new agGrid.Grid(el, gridOptions)
205-
206-
gridOptions.columnApi.autoSizeColumn("__row__")
207-
gridOptions.columnApi.autoSizeColumns($names)
208+
gridOptions.columnApi.autoSizeAllColumns()
208209
end
209210
onimport(w, handler)
210211
end
@@ -242,10 +243,8 @@ function _showtable_async!(w, schema, names, types, rows, coldefs, tablelength,
242243
gridOptions.components = Dict(
243244
"rowNumberRenderer" => RowNumberRenderer
244245
)
245-
246246
this.table = @new agGrid.Grid(el, gridOptions)
247-
gridOptions.columnApi.autoSizeColumn("__row__")
248-
gridOptions.columnApi.autoSizeColumns($names)
247+
gridOptions.columnApi.autoSizeAllColumns()
249248
end
250249
onimport(w, handler)
251250
end

0 commit comments

Comments
 (0)