@@ -155,13 +155,13 @@ function showtable(table, options::Dict{Symbol, Any} = Dict{Symbol, Any}(); dark
155
155
156
156
showfun = async ? _showtable_async! : _showtable_sync!
157
157
158
- showfun (w, names, types, rows, coldefs, tablelength, id, options)
158
+ showfun (w, schema, names, types, rows, coldefs, tablelength, id, options)
159
159
160
160
w
161
161
end
162
162
163
- function _showtable_sync! (w, names, types, rows, coldefs, tablelength, id, options)
164
- options[:rowData ] = JSONText (table2json (rows, names , types))
163
+ function _showtable_sync! (w, schema, names, types, rows, coldefs, tablelength, id, options)
164
+ options[:rowData ] = JSONText (table2json (schema, rows , types))
165
165
handler = @js function (agGrid)
166
166
@var gridOptions = $ options
167
167
@var el = document. getElementById ($ id)
@@ -171,14 +171,13 @@ function _showtable_sync!(w, names, types, rows, coldefs, tablelength, id, optio
171
171
onimport (w, handler)
172
172
end
173
173
174
-
175
- function _showtable_async! (w, names, types, rows, coldefs, tablelength, id, options)
174
+ function _showtable_async! (w, schema, names, types, rows, coldefs, tablelength, id, options)
176
175
rowparams = Observable (w, " rowparams" , Dict (" startRow" => 1 ,
177
176
" endRow" => 100 ,
178
177
" successCallback" => @js v -> nothing ))
179
178
requestedrows = Observable (w, " requestedrows" , JSONText (" {}" ))
180
179
on (rowparams) do x
181
- requestedrows[] = JSONText (table2json (rows, names , types, requested = [x[" startRow" ] + 1 , x[" endRow" ] + 1 ]))
180
+ requestedrows[] = JSONText (table2json (schema, rows , types, requested = [x[" startRow" ] + 1 , x[" endRow" ] + 1 ]))
182
181
end
183
182
184
183
onjs (requestedrows, @js function (val)
@@ -208,25 +207,23 @@ function _showtable_async!(w, names, types, rows, coldefs, tablelength, id, opti
208
207
end
209
208
210
209
# directly write JSON instead of allocating temporary dicts etc
211
- function table2json (rows, names , types; requested = nothing )
210
+ function table2json (schema, rows , types; requested = nothing )
212
211
io = IOBuffer ()
213
212
print (io, ' [' )
214
213
for (i, row) in enumerate (rows)
215
214
if requested == nothing || first (requested) <= i <= last (requested)
216
215
print (io, ' {' )
217
- i = 1
218
- for col in Tables. eachcolumn (row)
219
- JSON. print (io, names[i])
220
- i += 1
216
+ Tables. eachcolumn (schema, row) do val, ind, name
217
+ JSON. print (io, name)
221
218
print (io, ' :' )
222
- if col isa Number && isfinite (col )
223
- JSON. print (io, col )
224
- elseif col === nothing
219
+ if val isa Number && isfinite (val )
220
+ JSON. print (io, val )
221
+ elseif val === nothing
225
222
JSON. print (io, " nothing" )
226
- elseif col === missing
223
+ elseif val === missing
227
224
JSON. print (io, " missing" )
228
225
else
229
- JSON. print (io, sprint (print, col ))
226
+ JSON. print (io, sprint (print, val ))
230
227
end
231
228
print (io, ' ,' )
232
229
end
0 commit comments