Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Button Click Change the Current Row Field

Issue

I want to change the "is_Active" field of the current table row to false when I click a button in that row. Additionally, I want the text and color of the button to change accordingly.

Resolution

To change the "is_Active" field of a row to false when a button is clicked, you need to use JavaScript and run a query to update the data in your backend. Here is one possible solution:

  1. In your table, add a button column and set the button label and color based on the value of "is_Active". For example, you could use this code in the button's Label property:
{{currentRow.is_Active ? "Deactivate" : "Activate"}}

And this code in the button's Color property:

{{currentRow.is_Active ? "rgb(237, 187, 153)" : "rgb(183, 232, 189)"}}

2. Add an onClick event to the button, using this code:

onClick: function(event, currentRow) {
// Update the is_Active field to false in your backend
// For example, using AJAX or a serverless function
// Fetch the updated data and set it to the row using setCurrentRow()
// For example:
currentRow.is_Active = false;
setCurrentRow(currentRow);
}

This code will update the "is_Active" field to false when the button is clicked, and change the label and color of the button accordingly. You will need to replace the comments with your own code to update the data in your backend and fetch the updated data.