I’m training my JS muscle and have been playing around with the scripting block.
I’ve extended the currency conversion example, however I can’t figure out have to get my output text aligned when they’re nested?
Not that I am aware, but I have also looked for a way without success. @Stephen_Suen should comment on this.
Yes, it’s tricky, but all you have to do is add a new JSON item after all rows have been added that includes the sums of any specific columns.
The output.table() method is simply exposing the array of JSON item objects and this makes it possible to put also sorts content above, below, and even inside data rows. As such, it’s relatively easy to create aggregations, group-by’s, and averages, etc.
Currently, there’s no built-in way to exclude the index column when using output.table. We’d love to hear how you’re using this output method — are you typically passing in something like queryResult.records?
There are actually two vectors to this question - (i) hiding the index column, and (ii) use cases.
(i) I’d love to see a way to toggle the index column off, although, the current workaround is to generate a markdown table which is tedious, but useful.
(ii) I display records but more often than not, I’m using outbut.table() to render a grid of computational results like benchmarks, or aggregations, or text grids from other queries. Tables are one way to overcome the lack of UI formatting helpers.
I personally rarely use output.table() for queryResult.records.
I only ever output queryResult.records for debugging purposes, and for debugging, I don’t care if the index column appears or not.
I usually use output.table() for arrays of objects with keys of my own choosing based on the data I that I want to display. Usually, just before output.table(), I map the key names to more user-friendly names and omit any keys that I don’t want to display.