#SelectedRow in a table

1 messages · Page 1 of 1 (latest)

minor phoenixBOT
#

Hello! I'm AppyBot, your Appsmith support assistant.

To set the selected row when a button in a table column is clicked, you can use the onRowSelected property of the Table widget combined with a JavaScript function to update the selected row state. Here?s how you can do it:

  1. Create a JSObject to manage the selected row state. Let's call it TableManager.

    export default {
      selectedRow: null,
    
      setSelectedRow: function(rowData) {
        this.selectedRow = rowData;
      }
    };
    
  2. Add a Button in your table column and set its onClick action to call the setSelectedRow function, passing the current row data.

    { { TableManager.setSelectedRow(currentRow)}}
    
  3. Access the selected row data anywhere in your app using:

    { { TableManager.selectedRow}}
    

This setup ensures that whenever a button in a specific row is clicked, the selectedRow in TableManager is updated to that row's data, which you can use elsewhere in your application.

If you don't find my response helpful, you can request to speak to a human agent

minor phoenixBOT
#

Hello! I'm Amelia with Appsmith Support.
Instead of using the selectedRow object of the table, you need to use the triggeredRow object: https://docs.appsmith.com/reference/widgets/table#triggeredrow-object
Let me know if this solves the problem or if you are facing further issues.

This page provides information on using the Table widget to display data in tabular format, trigger actions based on user interaction, and work with paginated data sets of any size.

winter robin
#

Yes that sorted it thank you, I worked it out shortly after posting this issue 🙂

minor phoenixBOT
#

It looks like you've already resolved the issue based on your previous message. If you have any more questions or need further assistance with anything else, feel free to ask. I'm here to help!

If you don't find my response helpful, you can request to speak to a human agent