Long post short, the right code should be:
{{getTrackPositions.dataArray[0].TRACKNAME.map((track, index) => [String(track), getTrackPositions.dataArray[0].POSNAME[index]])}}
Long post long...you want an array of arrays like this:
[
["21","Shed 1"],
["21","Shed 2"],
["21","Shed 3"],
["22","Dock North"],
["22","Dock South"]
]
For the initial suggested code provided, I loaded and parsed sample data as a (very) simple CSV through a file input component, then ran a "Query JSON with SQL" (select * from {{fileDropzone1.parsedValue[0]}}
) and took the data from there, which is this array of objects:
[
{
"TRACKNAME": "21",
"POSNAME": "Shed 1"
},
{
"TRACKNAME": "21",
"POSNAME": "Shed 2"
},
{
"TRACKNAME": "21",
"POSNAME": "Shed 3"
},
{
"TRACKNAME": "22",
"POSNAME": "Dock North"
},
{
"TRACKNAME": "22",
"POSNAME": "Dock South"
}
]
And this can be manipulated into the right for with {{query1.data.map(obj => Object.values(obj))}}
...but clearly my mockup data isn't reflecting your real life data...so switching to importing the CSV into the Retool DB and a straightforward SQL query, I get the following dataArray:
[
{
"id": [
1,
2,
3,
4,
5
],
"POSNAME": [
"Shed 1",
"Shed 2",
"Shed 3",
"Dock North",
"Dock South"
],
"TRACKNAME": [
21,
21,
21,
22,
22
]
}
]
Which can be converted with {{query2.dataArray[0].TRACKNAME.map((track, index) => [String(track), query2.dataArray[0].POSNAME[index]])}}
.
If your data is still not working with this new code, please paste in the value of getTrackPositions.data and getTrackPositions.dataArray and I'm sure we can figure it out...