@@ -155,13 +155,13 @@ function showtable(table, options::Dict{Symbol, Any} = Dict{Symbol, Any}(); dark
155155
156156 showfun = async ? _showtable_async! : _showtable_sync!
157157
158- showfun (w, names, types, rows, coldefs, tablelength, id, options)
158+ showfun (w, schema, names, types, rows, coldefs, tablelength, id, options)
159159
160160 w
161161end
162162
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))
165165 handler = @js function (agGrid)
166166 @var gridOptions = $ options
167167 @var el = document. getElementById ($ id)
@@ -171,14 +171,13 @@ function _showtable_sync!(w, names, types, rows, coldefs, tablelength, id, optio
171171 onimport (w, handler)
172172end
173173
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)
176175 rowparams = Observable (w, " rowparams" , Dict (" startRow" => 1 ,
177176 " endRow" => 100 ,
178177 " successCallback" => @js v -> nothing ))
179178 requestedrows = Observable (w, " requestedrows" , JSONText (" {}" ))
180179 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 ]))
182181 end
183182
184183 onjs (requestedrows, @js function (val)
@@ -208,25 +207,23 @@ function _showtable_async!(w, names, types, rows, coldefs, tablelength, id, opti
208207end
209208
210209# 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 )
212211 io = IOBuffer ()
213212 print (io, ' [' )
214213 for (i, row) in enumerate (rows)
215214 if requested == nothing || first (requested) <= i <= last (requested)
216215 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)
221218 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
225222 JSON. print (io, " nothing" )
226- elseif col === missing
223+ elseif val === missing
227224 JSON. print (io, " missing" )
228225 else
229- JSON. print (io, sprint (print, col ))
226+ JSON. print (io, sprint (print, val ))
230227 end
231228 print (io, ' ,' )
232229 end
0 commit comments