Simple random item from data

hello community, I am totally new here and with zero coding experience, so please forgive my silly questions.
I have a data list. When the user click on a button I want 1 random item from my data list to show.
That’s it. I just can’t get my head round on how to do this. Please help :pray:

Hello LuckyG, welcome to Glide and the community forum.

In the data editor: create a table with your list of items. You’ve probably already done this.

In the layout editor:

  • Create a new tab and add a collection component to it whose data source is the table with the list. You should see the list of items.
  • Select the collection component by clicking on it. On the right hand side, you can configure this collection.
  • In the general tab, at the bottom in the options area, limit the number of items to be displayed to 1.
  • In the options tab directly right of the general tab, set the sort setting to random.
  • If you want to control when the list shuffles, add a button component to the screen, for instance above the collection. and associate the action called “Data → Shuffle” to the button. Each click of the button will shuffle the collection.

There you go. Now every time the page is reloaded or the button is clicked, the collection will display a single element at random.

1 Like