Use data from Expanded Row

Hello everyone! I am newbie at this so hope you will excuse if this is a very simple fix.

  • Goal: What I am trying to achieve is to show on a expanded table some values from my table that are related to the the expanded row itself. So it should in my case compare the url of the expanded row and find show the relevant value.
  • Steps: What I have done so far is the following. Create a first table with a query to select all the value for my main table. Created a javascript that should in theory get the url of the expanded row. Created another query that select the value that I need if the URL is equal to the url returned by the javascript. However the problem seems that the javascript does not return value when a row is expanded. Here is my full code so far.

Main SQL Query:
SELECT * FROM "native_site";

Query to select specific url for the expanded row: (Query5)

SELECT
URL,
id,
gen_year,
gen_perm,
fin_year,
fin_perm,
gamb_year,
gamb_perm,
homepage_link
FROM
native_site
WHERE
url = {{ query6.data[0] }};

Javascript to get the url from the expanded row: (Query6)

function getExpandedRowData() {
if (table3.currentRow) {
return [table3.currentRow.url]; // Returns an array containing just the URL
}
return []; // Returns an empty array if no row is expanded
}

return getExpandedRowData();

  • Details: I am then using Query 5 as data source for my internal table (Table4) which is the one that should display inside the expanded row and using my query6 (the javascript) as event trigger on Expand Row.

    I think the first problem I have is that the javascrtipt is not returning the value of the url of the expanded row and this also could be why in my data source of the nested table I have the problem in the second screenshot.
    image

Is the problem the javascript? Am i not using correctly the CurrentRow to get the url of the main table3 to pass it on the second table? Or is the query? Any help would be much appreciated!

HI there @darl3190,

Not sure I understand what you're trying to do. But if I'm reading this correctly, then you should keep in the table the values from the MAIN SQL query that you want to refer to in the expanded row.

The {{currentRow}} and {{currentSourceRow}} variables can be used within the expanded row's components to refer to all of the values within your table. So in that case, you can add a component and refer to it like {{currentSourceRow.gen_year}}.

Does that make sense?

Hi Miguel,

Thank you so much, it works!