Sorting Structure Field

I have the following structure field in my blueprint and would like to sort the entries by “ffDateStart”.

ffRecords:
	type: structure
	label: 'Termine'
	translate: false
	columns:
		ffTitle:
			width: 2/6
		ffDateStart:
			width: 1/6
		ffDateEnd:
			width: 1/6
		ffTime:
			width: 1/6
		ffOnlineOK:
			width: 1/6
	fields:
		ffDateStart:
			type: date
			label: 'Datum'
			display: YYYY-MM-DD
			width: 1/2
		ffDateEnd:
			type: date
			label: 'Enddatum'
			display: YYYY-MM-DD
			width: 1/2
		ffTitle:
			type: text
			label: 'Titel'
			width: 1/2
		ffTime:
			type: time
			label: 'Uhrzeit'
			display: HH:mm
			width: 1/2
		ffOnlineOK:
			extends: fields/ffToggle
			label: 'Online'
			default: true
			width: 1/2
	sortBy: ffDateStart

The documentation says that you can sort by a specific field using “sortBy”. I quote: “Sorts the entries by the given field and order (i.e. title desc) Drag & drop is disabled in this case.” Unfortunately this does not work. The line “sortBy: ffDateStart” only prevents manual sorting, but has no other effect.

I look forward to any useful tips :slight_smile:

Tell the sortBy function whether to sort in ascending or descending order.
It worked in my test. Without asc or desc, the list is not sorted by date.
(For a better structure, I would position the sortBy at the top area.)

ffRecords:
	type: structure
	label: 'Termine'
	sortBy: ffDateStart asc # or desc
	translate: false
	columns:
		ffTitle:
			width: 2/6
		ffDateStart:

Thank you very much for your quick feedback. I have had less success with sorting. I have already tried the additions desc or asc - unfortunately no effect :confused: Here is a screenshot of what my order looks like :point_down:

Probably a bug, seems to work fine if the date field is just called date.

1 Like

I tried the code in a fresh starter kit and was able to reproduce the behaviour. I have tried lower case, but unsuccessfully.
In my installation, date is also called date and the sorting works fine.
An error is therefore plausible.

1 Like

That’s it! Thank you. After renaming the data field to „date“ it also works here. In this case “date” it is :slight_smile:

Thank you!

The solution is to write the field name in lower case letters in the sortBy statement! If I write “sortBy: ffdatestart desc” in the example shown above, it works!

1 Like