How to use run a query on an expanded row

Hi there,

Thanks for reaching out :slightly_smiling_face:

currentRow is defined from the table, so it works well when referenced directly inside nested component configurations or when dynamically referenced inside standalone components.

In nested component configurations:

@Skizhu provides an example of populating a component with {{currentRow}}.

:white_check_mark: You can expand on this same concept by filtering query data to only show values relevant to the current row. Here's an example where I'm passing in all of my nested data to the table in the expandable rows and then filtering inside the component set up:

With standalone components that are not nested in the table, you can pass currentRow from a component in the expanded row. Here's an example where I trigger a query from the expanded row (so currentRow is in scope) and then display that query in a standalone table. Note that the linter may warn you that currentRow is not defined, but it will be once you trigger the query from the table. In my case, I'm returning the currentRow object inside an array so that I can show it in another table.

:construction: This approach doesn't work well for nested components. You will run into issues if you have more than one row expanded at a time, the query will update all of the nested components with the same currentRow value.

:white_check_mark: As already mentioned in this thread, you could combine all of the data into the first table and then access it with currentSourceRow in the expanded rows

@cstork Where did you use the code {{ Promise.resolve(query1.trigger({additionalScope: {name: currentRow.name},})) }}? Since it has the {{}} it seems like you might be using this code in a transformer? If so, you cannot use .trigger() within a transformer. It needs to be used inside a run script event (without the {{}} around it) or in a Javascript query.

Again, you can pass the currentRow values to a query using additionalScope, but if you're displaying that query in a nested component, it will incorrectly update all expanded rows with the same data.

1 Like