Sharing one text box with two selectRows

Hi there,

  • I have a tabbed container (view 1, view 2)
  • In that container is two tables, table1, and table 2.
  • To the right of that table is a text box
  • Depending what 'tab' is selected, depends what table shows.
  • I'd like to show in that table a value form the selected row.

Is there a way to determine which table is 'in view' and then only take the selected row from that data?

Hopefully this makes sense, any help, as always, is appreciated.


Neil

Your best choice may be to store the value in a temp variable every time a row is selected and then read from the temp variable for the value of the text box... make sense?

1 Like

Hi Scott,

Yes, makes sense - was something I had in mind but was wondering if there was a more simple method (albeit that is also quite simple).

Thanks for the reply, i'll give that a try,
Neil

the tabbed container has a currentViewIndex property, you could use that in a ternary to do something like {{(container.currentViewIndex === 0) ? table1.selectedRow.data.name : table2.selectedRow.data.name}}, but that's a little clunky and doesn't scale well if you add more views

That worked a treat.....

However, is there a way to set the tempt state when I move to a different view on the (tabbed) container? - I can't find a way to attach an event handler to the buttons on the nav/tab......

I'd like to make it empty each time the tab changes.

Screen Recording 2023-01-24 at 16.45.15

add a change event to the container not the tab buttons

1 Like

of course! thanks

I agree with @dcartlidge as that was my initial thought as well.... but what you can do is on row select set an event handler to set the temp var
Screenshot 2023-01-24 at 10.49.04 AM

1 Like

That was the way I done it(in the gif above). But I used on Row Click.....

row select would be better, if they navigate up and down using the arrow keys then row click wouldn't fire and you'd be showing the wrong data

This is why it may be easier to let Retool components do the work on that part and use the table1.selectedRow.data and don't worry about how it was selected

Thanks Dave,

I used your method in the end. It also worked great - and especially with using the cursor keys.
Sorry @ScottR - I cheated on you :-p

Neil
Screen Recording 2023-01-24 at 17.39.26

2 Likes