Have a custom button in table .. onclick of that button wanted to show the selected row in json format in the model

Have a custom button in table .. onclick of that button wanted to show the selected row in json format in the model.

Hi @Madhavi_G Thanks for reaching out! Can you share more about what you mean by "json format in the model"?

You can certainly trigger events on click. One idea that comes to mind is to trigger a modal that pops open with a json component of the selectedRow data.

For opening a modal on click we have instructions here: http://community.retool.com/t/how-to-close-a-modal-from-a-table-using-js/1944/7

The modal could look like this:

Let me know if this isn't what you're looking for!

Thanq Tess for the quick Reply.. tht is working fine.. current issue is selectedRow.data is giving previously selected row not the current one

Have a table with View button.. on click of it.. am opening model with TextArea control.. which should be populated the currently selected row info in Json Format.

Here is the code for onlick of view button in table :

const resultRow = query4.data;
const jsonString = JSON.stringify(resultRow,null,2);

query4 :
select * from {{SourceLibraryCollection.data}} where _id ={{table1.selectedRow.data._id}};

this code is showing previously selected row info in the model.. can u please help me

Hi @Madhavi_G,

It sounds like the onclick event is being triggered at the same time as query4, so it doesn't have the updated data. Would it work for you to actually make query4 a manually triggered query & trigger that one off of the onclick event instead? Then, you can trigger the modal open query on success of query4 to ensure it has the new data

Hi Team,

by default Table has got Download button .. but we wanted to show this option only when there is a data in the table otherwise it should be hidden .. and also we wanted to show all hidden columns also in downloaded Excel file .. and we wanted to change the name of the excel file..

we are using 2.100.8 version of Retool.

please help me on this.

Hi @Madhavi_G

You can click the "fx" button to set any of the table buttons to be dynamic:

You could set it to only show when the table query has data:

When downloading, you have two native options:

1) Download raw data OFF: will only download the visible columns, will include any custom columns and custom mappers you've set on your table

2) Download raw data ON: will download all database columns even if they're hidden on the table, will not include any custom columns or custom mappers from the table settings

That said, you can't currently rename the file when using the native download button :disappointed:

The best way to implement naming the file yourself, is to use a custom button on the table, as we're chatting about here. Unfortunately, you can only have one custom button per table. Maybe you could have a button component next to the table if you need the custom button described above, as well as a custom download solution