This question was asked on Discord by a user rs4, following is the use-case:
In a column of a table I have added a button that opens a modal.
The modal contains a table, which populates its data with an API call.
The endpoint of the API requires a field ID fetched from the selected row of the table on the main page.
Whenever I open the modal by clicking the button it shows me the previously fetched data, meaning the API corresponding to the selected row ID is not hit again.
Step 1:
First, we could convert table column types into Button, by updating it on the property pane.
Step 2:
Next, drag and drop a new Modal (default name would be Modal1) on the canvas.
Step 3:
Open the table’s property pane, go to column properties of the desired row and update its onClick property to:
This doesn’t seem to work if the item in the Modal is a JSON form. Any insights?
If I create a form with some elements it works, but if I use a JSON form, it doesn’t. The same JSON form works fine if it’s just positioned on the page and not in a modal.
If I use the show (eye icon) to hide and then redisplay elements within the JSON form, it updates to reflect the correct information.
Hey @vernons, I didn’t understand your use case, are you trying to use a JSON form on the Modal? If that’s the case, it’s working well for me. Here is the API I’m using:
https://randomuser.me/api/
On the button onClick property, I’m running an API and showing a Modal, that has a JSON form binded to the API that’s called. I’m attaching the recording of the same:
Hi @vihar, my use case is to pop up a modal that has a JSON form populated with details when a row on my main page is selected.
It’s similar to your demo, with the differences being the modal being triggered when a row is clicked (instead of a button) and a the JSON form in the modal being more complex.
I’m not sure why what I was doing yesterday wasn’t working. Today as I was refactoring the form for use with some other lists, I used the following pattern:
I think the typo was when I typed the item into the forum. I guess I didn’t use cut/paste, since it’s correct in the application.
I’m still not sure why the second case – with the correct spelling, of course – doesn’t work, but I’ve just reconfirmed that again. If I use the run and then the showModal sequentially, as in the first example, the data is populated correctly, but when I use the callback style in the second example, the data reflects data from the previously selected row.
Anyway, the sequential style works fine, so I’ll use that.