Mar 19, 2020 10:26 AM
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?
Anyone who knows if I’m doing something wrong?
Mar 20, 2020 08:51 AM
This is actually a property of how whitespace is handled within template literals (strings that use the ` symbol). You can do one of the following:
if (true) {
output.text(`First line
Second line
Third line`);
}
output.text
calls, e.g.if (true) {
output.text('First line');
output.text('Second line');
output.text('Third line');
}
Mar 20, 2020 09:06 AM
Thank you @Stephen_Suen,
Mar 20, 2020 12:21 PM
Have you thought about using the output.table() method?
Example…
You can also do some clever things with Markdown and tables.
Mar 21, 2020 08:12 AM
Or do it all in one output.text()
call.
let line1 = "Line one";
let line2 = "Line two";
let line3 = "Line three";
// Method 1
output.text(`${line1}\n${line2}\n${line3}`);
// Method 2
let multipleLines = [line1, line2, line3].reduce((total, current) => {
return total + current + "\n";
}, "");
output.text(multipleLines);
Mar 23, 2020 06:02 AM
Hi @Bill.French thanks for the tip, do you know if there’s a way to not show the index number on the side?
Also do you know if it’s possible to make total under a few of the columns?
Mar 23, 2020 06:14 AM
That also works like a charm. Thank you @kuovonne
Mar 23, 2020 08:26 AM
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.
The world (of Airtable) is your oyster. :winking_face:
Mar 23, 2020 01:55 PM
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
?
Mar 23, 2020 02:02 PM
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 likequeryResult.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.