Creating multidimensional arrays to work with nested list view

Hi! I'm trying to figure out how to use nested list view.

Once a user selects a row, this opens ListView1, with all of the selected order's items.
In this listview1, I now need to display each item's sub-items, using the item's ID, in listview2.

Reading a different discussion from Aug (here) I understand that I need to create a multi-dimensional array, however I'm not sure how to create it.

I am able to merge the "items" query and left join a "sub-items" query, however I don't think this is what I'm looking for.

Any hint? Is it even possible?

Thank you very much!

@victoria

Hey @ronasilb!

It looks like you're on the right path here. Someone very recently asked a similar question in this thread.

The suggestion there uses a separate Query JSON with SQL query but you might be able to just do the formatting you need in the join query you're creating. If you're using something like Postgres to query your data you can try using ARRAY_AGG, for instance:

SELECT
  u.email,
  ARRAY_AGG(o.status) AS order_statuses
FROM
  users u
  JOIN orders o ON u.id = o.user_id
GROUP BY
  u.email;

From there you can use the nested list view notation.

Let me know if that helps or raises any other questions! There are likely other syntaxes that work for different resource types as well.

1 Like