Filtering child listView based on information from parent

Imagine I have database tables:

customers, with columns customerId, firstName, lastName
products, with columns productId, name, description
orders, with columns customerId, productId, quantity

Now I have a listView of customers (customerListView), and within that a nested listView (orderListView) with information about the products ordered by that customer.

Based on the section on nesting in Build custom views using repeatable components | Retool Docs I thought I'd be able to write backing queries:

select * from customers

and

select p.productId, p.name, p.description, o.quantity 
from orders o 
inner join products p
on o.productId = p.productId
where o.customerId = {{ customerListView.item.customerId }}

However this doesn't seem to work. The autocomplete doesn't even suggest customerListView.item . Am I doing something wrong? Is there some other way to achieve this?

Hello @Stereotomy

access customer data within a nested listView in Retool, use {{ customerListView.data.item.customerId }} in the inner listView's backing query. This will correctly fetch orders for the selected customer.

4 Likes

yes, .item will reference the current element from the parent listView so you should be able to filter by that value properly

1 Like