How to loop through a query / table, transform and use that in a custom column

Hi All,

with some awesome help I got below code working but I made the mistake to use the table selected row which off course will not work if I want all rows to get their unique data.

var category = [];

for (i=0;i<table1.selectedRow.data.bol_categories.length;i++){
  category.push(table1.selectedRow.data.bol_categories[i].name)
}

return category.join(",")

In general what is the correct / best way to loop through a query or table? For somebody who is a JS dummy. I always seem to get stuck by the objects and understanding how to go through them one by one

do this at the top
var myData = formatDataAsArray(query2.data.bol.categories);
then use
i < myData.length in the loop....

thanks, as always @ScottR is here to help :slight_smile:

Tried below but no result

var myData = formatDataAsArray(query2.data.bol_categories);
var category = [];

for (i=0;i<myData.length;i++){
  category.push(myData[i].name)
}

return category.join(",")

this is my query2 result

image

How many bol_categories do you expect?

So this is the result when I use it on the selected row, that is exactly what I need.
So I have a custom column that should show below value per row

"Kamperen & Outdoor,Hengelsport,Roofvis,Kunstaas,Meerval,Kunstaas"

which is transformed from

[{"id":109,"name":"Kamperen & Outdoor","bol_id":15270,"bol_category_id":null,"results":12000,"pivot":{"product_data_id":642640,"bol_category_id":109}},{"id":1579,"name":"Hengelsport","bol_id":15592,"bol_category_id":109,"results":12000,"pivot":{"product_data_id":642640,"bol_category_id":1579}},{"id":1595,"name":"Roofvis","bol_id":50090,"bol_category_id":1579,"results":12000,"pivot":{"product_data_id":642640,"bol_category_id":1595}},{"id":5922,"name":"Kunstaas","bol_id":50212,"bol_category_id":1595,"results":7406,"pivot":{"product_data_id":642640,"bol_category_id":5922}},{"id":11191,"name":"Meerval","bol_id":64907,"bol_category_id":1579,"results":5651,"pivot":{"product_data_id":642640,"bol_category_id":11191}},{"id":11232,"name":"Kunstaas","bol_id":64908,"bol_category_id":11191,"results":5432,"pivot":{"product_data_id":642640,"bol_category_id":11232}}]

You should use similar code to loop through that result as well....sorry but maybe I am a little confused... wasn't this resolved in the other post?
I took the above data you posted and ran the code above as well and see:
"Kamperen & Outdoor,Hengelsport,Roofvis,Kunstaas,Meerval,Kunstaas"

@ScottR sorry if I was not clear. The problem is that with the updated query I am not getting any results.

it only works when I use

table1.selectedRow.data.bol_categories.length;i++){

OK so let's start from the beginning.... you have a table where you want to only display the categories in a comma separated "list" such as
"Kamperen & Outdoor,Hengelsport,Roofvis,Kunstaas,Meerval,Kunstaas"
The above code does not work....
If all of the above is true, can you send me the data populating your table so I can reconstruct on my end and see how to make this work..... because from what I can tell this should all be working already... :slight_smile: gremlins....they live

{{search.data[i].bol_categories.map(d=>d.name).toString()}} in the bol_categories column Mapped Value field