I seem to be stuck and am getting lost on how to best solve this.
- I have a table hooked up to GraphQL.
- One of the row’s has an array of three values. They look like this: 0550ebdc-cb43-4571-b686-44c09e1a04f4,0e111f5d-40d6-4532-90b7-8926290258f5,3978313b-d90b-4595-b41f-48b72d405c15
- I am trying to take that row when it is selected, and render those three values into another column of a table with each ID associated to a different row in the same Column. Ideally in this table I would render not the ID but a human-friendly name for the ID. I.E. Name.
Hey Geoff, I’m not super clear on what exactly you’re trying to do. I think you’d want to use a transformer to change your data from one format to another. Sounds like you want to split one row into multiple rows. Something like creating an array and putting each uuid and the respective info into that with a for loop might work? If you have a block of example data and how you want that to look, we might be able to help you write the JS
Hi @yogi !
To clarify, imagine I have a list of people (you see one above, Jame Lunk) and a field that stores an array of the credit cards they own. Again, you can see the credit card ID’s in the above screenshot. (“0550…”, etc)
I would then have a separate table that shows a list of the credit card names (and hides the IDs). I would like to allow a user to click on the name of the credit cards and have those array’s saved into the field above “0550”.
So it’s a matter of using an array of ID’s from one table to select (I assume using a multi-select table) the credit card a user already has. The goal being that you could ctrl-click on each credit card and add or remove credit cards from the other table’s array of credit card IDs.
I would imagine I would need a for loop that would take the ID’s from the other table and select the matching cards in the above multi-select table. If you look at the below doc’s for multi-select they are pretty confusing. value vs. values? Not sure why it doesn’t say possible_values vs. selected_values or something similar
@yogi or any other retoolers, any thoughts on this?
Ah yeah that’s pretty confusing on the Multi Select. We’d probably want to keep value, as for every single component we use
.value to get the current value of the component, but for
values we might be able to rename it to
possibleValues or something like that.
For your question, looks like you have a few steps:
- Get the values from the row into the multiselect possible values. You can do table1.selectedRow.data.cards (assuming your column is named cards and your table is table1).
- You’d need to somehow know that id X is Visa / Mastercard / etc. I assume you already have a way to do this? If you need to write some code, you could maybe use a transformer to convert the ids into names, and ut these values into the labels field in the multi select
- You can add a query to run ‘on select’ in the multi select. This query can write back to the data source when you select / deselect some cards
Hope that helps! Let me know if I can clarify anything
I think what I am trying to do is very straight forward but not easy to do (for me) in retool.
If you still need a picture, let me know.
Hi @Geoff, your entry looks like an array of strings from the looks of it. You should be able to use the formatDataAsArray(array) function and then it should be possible to refer to its values itself.
Thanks @zimmerst85 I will try that!