Reorder items in repeater using cms

I have setup a repeater using cms. the items appear in the repeater but I can not reorder them.

I sorted the items as desired in the live collection and synced. They still appear in the wrong order?

It’s still using the _dateCreated data to order your items. But you can reorder them based on a data. And to do that you will need a small JS code.

let repeaterData = $w('#repeaterId').data;
repeaterData.sort() //use sort to sort the array (you will need different sort system)
$w('#repeaterId').data = [];
$w('#repeaterId').data = repeaterData;

//sort based on createdDate (older first)
repeaterData.sort((a, b) => a._dateCreated - b._dateCreated );
$w('#repeaterId').data = [];
$w('#repeaterId').data = repeaterData;

Array.prototype.sort() - JavaScript | MDN (

1 Like

Thanks… thats above my ability at the moment. Surely there is a way without code?

I don’t remember CMS dataset features well I don’t use them at the moment last time I used dataset to connect data to my elements year was 2019 so I don’t remember :slight_smile:

1 Like

The collections are just for you, sorting and filtering in the database will have no impact on your live site. This is purely so you can find things and organise stuff whilst working on your collection for example.

For website pages you can use the default options in the dataset connected to your repeater to sort and filter but it’ll be static of course, whatever you set up is what people will see on the page. You’d have to use code to allow the page to be sorted or filtered on the live page by website visitors (except maybe you can now filter stuff with a dropdown without code? I’ve not tried it but I noticed you can connect a dropdown to CMS nowadays so presumably you don’t need any code for that and it’s as simple as connecting the dropdown.)

Is there really no way to reorder the items in your CMS so that they show up in a particular order on your website (assuming you have no idea how to make use of coding, as suggested above)? I noticed that my items are appearing with the most recent one first. I need it in the opposite order. That means that I should have input my items in reverse order for them to show up in the correct order on the website. This seems like a glaring oversite that wrecks the point of having repeaters, if they can not be reordered as needed. What am I missing? Can someone either verify that there is nothing you can do to reorder your items in the repeater on your webpage, or tell me how to do it? Many thanks :slight_smile:

The order must be set via the dataset that is connected directly to the repeater. Use the settings, scroll all the way to the bottom where it says “sort”.