@@ -14,6 +14,7 @@ function __init__()
1414 for f in [" ag-grid.js" , " ag-grid.css" , " ag-grid-light.css" , " ag-grid-dark.css" ]
1515 push! (ag_grid_imports, normpath (joinpath (@__DIR__ , " .." , " deps" , " ag-grid-$(version) " , f)))
1616 end
17+ pushfirst! (ag_grid_imports, normpath (joinpath (@__DIR__ , " rowNumberRenderer.js" )))
1718end
1819
1920to_css_size (s:: AbstractString ) = s
@@ -73,7 +74,7 @@ function showtable(table, options::Dict{Symbol, Any} = Dict{Symbol, Any}();
7374 height = 500
7475 if tablelength != = nothing
7576 # header + footer height ≈ 40px, 28px per row
76- height = min (40 + tablelength* 28 , height)
77+ height = min (50 + tablelength* 28 , height)
7778 end
7879 end
7980
@@ -123,18 +124,30 @@ function showtable(table, options::Dict{Symbol, Any} = Dict{Symbol, Any}();
123124 end
124125 end
125126
126- coldefs = [(
127- headerName = n ,
128- editable = cell_changed != = nothing ,
129- headerTooltip = types[i],
130- field = n ,
131- sortable = ! async,
132- resizable = true ,
133- type = types[i] <: Union{Missing, T where T <: Number} ? " numericColumn" : nothing ,
134- filter = async ? false : types[i] <: Union{Missing, T where T <: Dates.Date} ? " agDateColumnFilter" :
135- types[i] <: Union{Missing, T where T <: Number} ? " agNumberColumnFilter" : true
127+ coldefs = [Dict (
128+ : headerName => string (n) ,
129+ : editable => cell_changed != = nothing ,
130+ : headerTooltip => string ( types[i]) ,
131+ : field => string (n) ,
132+ : sortable => ! async,
133+ : resizable => true ,
134+ : type => types[i] <: Union{Missing, T where T <: Number} ? " numericColumn" : nothing ,
135+ : filter => async ? false : types[i] <: Union{Missing, T where T <: Dates.Date} ? " agDateColumnFilter" :
136+ types[i] <: Union{Missing, T where T <: Number} ? " agNumberColumnFilter" : true ,
136137 ) for (i, n) in enumerate (names)]
137138
139+ pushfirst! (coldefs, Dict (
140+ :headerName => " Row" ,
141+ :editable => false ,
142+ :headerTooltip => " " ,
143+ :field => " __row__" ,
144+ :sortable => ! async,
145+ :resizable => true ,
146+ :type => " numericColumn" ,
147+ :cellRenderer => " rowNumberRenderer" ,
148+ :filter => false
149+ ))
150+
138151 options[:onCellValueChanged ] = onCellValueChanged
139152 options[:columnDefs ] = coldefs
140153 options[:multiSortKey ] = " ctrl"
@@ -182,10 +195,15 @@ end
182195
183196function _showtable_sync! (w, schema, names, types, rows, coldefs, tablelength, id, options)
184197 options[:rowData ] = JSONText (table2json (schema, rows, types))
185- handler = @js function (agGrid)
198+ handler = @js function (RowNumberRenderer, agGrid)
186199 @var gridOptions = $ options
187200 @var el = document. getElementById ($ id)
201+ gridOptions. components = Dict (
202+ " rowNumberRenderer" => RowNumberRenderer
203+ )
188204 this. table = @new agGrid. Grid (el, gridOptions)
205+
206+ gridOptions. columnApi. autoSizeColumn (" __row__" )
189207 gridOptions. columnApi. autoSizeColumns ($ names)
190208 end
191209 onimport (w, handler)
@@ -217,10 +235,16 @@ function _showtable_async!(w, schema, names, types, rows, coldefs, tablelength,
217235 " rowCount" => tablelength
218236 )
219237
220- handler = @js function (agGrid)
238+ handler = @js function (RowNumberRenderer, agGrid)
221239 @var gridOptions = $ options
222240 @var el = document. getElementById ($ id)
241+
242+ gridOptions. components = Dict (
243+ " rowNumberRenderer" => RowNumberRenderer
244+ )
245+
223246 this. table = @new agGrid. Grid (el, gridOptions)
247+ gridOptions. columnApi. autoSizeColumn (" __row__" )
224248 gridOptions. columnApi. autoSizeColumns ($ names)
225249 end
226250 onimport (w, handler)
0 commit comments