I have an app where there is a table called items with 3 columns, id, price, and description
2.When someone clicks on the description of a row in that table, I want a modal called RequestDetailModal to open that has a table that shows all of the requests for that item.
I am almost there, but can't figure out the last bit
I have created a query show_item_requests that populates the table in the modal
I have set it up so that the WHERE statement in the show_item_requests is looking for the parameter {{description}}
WHERE
description = {{description}}
I have set up the event handler in the modal so that when the modal opens, it runs a script that triggers the query. For now I hard coded the parameter value, and when I change it manually it returns the correct rows
In the app, I put an event handler on the Description column in the table that also runs a script that opens the modal correctly
RequestsDetailModal.show()
When I click on the Description column in a row in the table in the App, it correctly opens RequestsDetailModal and returns the data from show_item_requests. For now, it's just filtered for the hard coded value I put into the script in the modal, but I'd like it to filter for the cell I clicked on in the table in the App.
What I can't figure out is how to make it so that RequestsDetailModal.show() passes the parameter from the selected cell to the script in the modal.
When they click the description, I think currentSourceRow.Description should have the description they click that you can pass as the parameter to show_item_requests.
Thanks! Yes, I've been trying that, but I seem to be doing something wrong, and am wondering if I'm just confused about the syntax. I feel like this should work, but as soon as I replace the hard coded value in the trigger() statement, the query returns "No results found"
Here is what I have in the javascript in the main table
I don't think const description= currentRow.description; is carrying through to the modal query (that variable is probably only valid in the event).
Can you try setting the modal trigger to
show_item_requests.trigger({
additionalScope: {
description: table1.selectedRow.description //table1 is whatever your table name is
}
});
If that doesn't work or you don't like relying on the selection in a row of the table, another approach might be to set a variable and update your table event code to:
const description= currentRow.description;
await variable1.setValue(description); //set the state variable
RequestsDetailModel.show();