Help with Updating Text Box Based on Selected Tab in Retool

Hello Retool Community,

I’m working on a Retool app where I need to update a text box with different strings based on the selected tab in a tab container. Here’s what I’ve set up so far and the issue I’m facing:

Current Setup:

  1. Tab Container:
  • I have a tab container with two tabs: "T" and "C".
  1. Event Handler:
  • I’ve defined an event handler that updates a variable whenever the tab is changed.
  1. Transformer:
  • I’ve created a transformer to generate the appropriate string based on the tab selected.

// Initialize variables to store data
const repTData = rep_t_in_selected_timeframe.data;
const totalData = total_t_in_selected_timeframe.data;
const repCData = rep_c_in_selected_timeframe.data;
const totalCData = total_c_in_selected_timeframe.data;

// Get the selected tab value
const selectedTab = rep_count_tab_container.value;

let headerText = '';
let repCount = 0;
let totalCount = 0;

if (selectedTab === 'T') {
repCount = repTData.rep_count || 0;
totalCount = totalTData.total_count || 0;
headerText = Replied T Count (${repCount} out of ${totalCount} in total);
} else if (selectedTab === 'C') {
repCount = repCData.replied_count || 0;
totalCount = totalCData.total_count || 0;
headerText = Replied C Count (${repliedCount} out of ${totalCount} in total);
}

// Return the header text
return headerText;

@RonR You can directly set yourTransformer.value as the default property in the textBox.

Hey @RonR

Let me know if @ZeroCodez suggestion worked for you :slightly_smiling_face: