@@ -14,6 +14,7 @@ function __init__()
14
14
for f in [" ag-grid.js" , " ag-grid.css" , " ag-grid-light.css" , " ag-grid-dark.css" ]
15
15
push! (ag_grid_imports, normpath (joinpath (@__DIR__ , " .." , " deps" , " ag-grid-$(version) " , f)))
16
16
end
17
+ pushfirst! (ag_grid_imports, normpath (joinpath (@__DIR__ , " rowNumberRenderer.js" )))
17
18
end
18
19
19
20
to_css_size (s:: AbstractString ) = s
@@ -73,7 +74,7 @@ function showtable(table, options::Dict{Symbol, Any} = Dict{Symbol, Any}();
73
74
height = 500
74
75
if tablelength != = nothing
75
76
# header + footer height ≈ 40px, 28px per row
76
- height = min (40 + tablelength* 28 , height)
77
+ height = min (50 + tablelength* 28 , height)
77
78
end
78
79
end
79
80
@@ -123,18 +124,30 @@ function showtable(table, options::Dict{Symbol, Any} = Dict{Symbol, Any}();
123
124
end
124
125
end
125
126
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 ,
136
137
) for (i, n) in enumerate (names)]
137
138
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
+
138
151
options[:onCellValueChanged ] = onCellValueChanged
139
152
options[:columnDefs ] = coldefs
140
153
options[:multiSortKey ] = " ctrl"
@@ -182,10 +195,15 @@ end
182
195
183
196
function _showtable_sync! (w, schema, names, types, rows, coldefs, tablelength, id, options)
184
197
options[:rowData ] = JSONText (table2json (schema, rows, types))
185
- handler = @js function (agGrid)
198
+ handler = @js function (RowNumberRenderer, agGrid)
186
199
@var gridOptions = $ options
187
200
@var el = document. getElementById ($ id)
201
+ gridOptions. components = Dict (
202
+ " rowNumberRenderer" => RowNumberRenderer
203
+ )
188
204
this. table = @new agGrid. Grid (el, gridOptions)
205
+
206
+ gridOptions. columnApi. autoSizeColumn (" __row__" )
189
207
gridOptions. columnApi. autoSizeColumns ($ names)
190
208
end
191
209
onimport (w, handler)
@@ -217,10 +235,16 @@ function _showtable_async!(w, schema, names, types, rows, coldefs, tablelength,
217
235
" rowCount" => tablelength
218
236
)
219
237
220
- handler = @js function (agGrid)
238
+ handler = @js function (RowNumberRenderer, agGrid)
221
239
@var gridOptions = $ options
222
240
@var el = document. getElementById ($ id)
241
+
242
+ gridOptions. components = Dict (
243
+ " rowNumberRenderer" => RowNumberRenderer
244
+ )
245
+
223
246
this. table = @new agGrid. Grid (el, gridOptions)
247
+ gridOptions. columnApi. autoSizeColumn (" __row__" )
224
248
gridOptions. columnApi. autoSizeColumns ($ names)
225
249
end
226
250
onimport (w, handler)
0 commit comments