Home App Docs Blog Github

Ordering of 'repeat for each' feature

So, I want to use the data ‘repeat for each’ feature to make my section independent of the number of data items I have. Next to this, I would also like to be able to change the ordering based on my preferences without having to specify a special data field on which to base the ordering on. Now, my question is, is this possible?

Builder content link

What are you trying to accomplish
I want to change the ordering of the data ‘repeat for each’ option, without having to use a predefined ordering datafield.

Hi @DanielVerloop , yes this is definitely possible. Looking at your store it looks like you are using a Builder model, and the repeat feature will be based on the explicit order set in the Fish Tank content section in your content hub: Builder.io: Drag and drop page builder and CMS

drapContentOrder

To change the order, click the double line icon and drag the items to the order you want.

In order to have your change populate on the site you may need to re-bind the data for it to show the updated order. I have gone ahead and done that in your store, please check it out and let me know if you have any other questions

1 Like

Alright thanks for the help.

Now suppose I would use an API instead of using a Builder model, would the order then be determined by the request only?

@DanielVerloop ideally the order would be set from the API before being bound in Builder. That being said, if you want to manipulate data from an API, you can do so in the JS/CSS editor within the data tab.

Here you can manually fetch data and run any JS to order/change the response to display on your page.

You can find more info on advanced data binding in our docs here: Advanced data fetching in Builder.io - Builder.io

And for adding custom code here: Adding custom code in the Builder.io visual editor - Builder.io

1 Like