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:
- Tab Container:
- I have a tab container with two tabs: "T" and "C".
- Event Handler:
- I’ve defined an event handler that updates a variable whenever the tab is changed.
- 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;