How to display an array of data (From Session Storage) inside a unique repeat?

Hey all,

I have a repeat on my page. Each item has a unique id.

I have a click event that sends more data from that repeat (after a API call) to a session storage element in an array.

This works perfectly, and I can send different data to the array each time, so I might end up with 4/5 unique array data items.

What I can’t seem to figure out, is a condition, to show the array data that has a ‘id’ that matches the ‘id’ inside the repeat.

I’ve tried data detail with no luck. I’ve tried session storage manager, including the id as a variable under the array in the schema to try and run a ‘where’ command, but that doesn’t seem to work either.

Appreciate any pointers here…

Hey there @mgaussie!

I don’t quite understand your question, but I believe you are wanting to access $id within a where()?

Hi @Antony!

So, I have a repeat that gets data from an API, this displays 25 records on the page.

Each record has a ‘Get More Info’ button.

Once I click that, I call another API via SC and I can display that on that additional information on that record. I use a conditional region to show/hide the area that holds more data based on the id of the record in the repeat matching the id in the data returned from the API.

This all works great!

Now, if I press the ‘Get More Info’ button on the next item in the repeat on the page, it also works fine - but then both repeat items show the same data, the new data from the latest request.

What I need to achieve, is to store the returned data from the update API in an array somewhere, so that if a user clicks Get More Info on 3/4 or more records, I can show only the relevant data on that specific, unique record - I just can’t seem to figure out how to get the outcome I need. I’m trying Session Storage and Array components. I can’t use Data Store as that doesn’t handle arrays only single variables.

Is that a bit clearer?

Interesting!

Do Data Stores definitely not support arrays? I’ve never tried that…

I guess if the number of arrays that comes back from the api is specific you could create a data store for each array type with an extra field showing which original it comes from…

A post specifically on how to create multi-dimensional data structures in Wappler would be interesting to read the responses to!

You can define the server connect inside the repeat. That way, when you load it, it will not override the previous object. Each row in the repeat will have its own instance of the SC.

3 Likes

Thanks @sid this seems like the solution! Trying it out now.

This has worked perfectly. Thank you!

1 Like