This is not controlled by the Combo Box widget directly. The widget will display the items based on the sorting order coming from the datasource.
A common approach is to prepare the datasource with a custom sort order.
For example, create a helper attribute: SortOrder
Then when loading the list:
Then configure the datasource sorting:
SortOrder = Ascending Country Name = Ascending
The result will be:
✓ Algeria ✓ Benin □ Angola □ Botswana □ Cameroon ...
The important part is that the Combo Box does not reorder association values automatically based on selection state, so the ordering logic needs to happen in the datasource/microflow.
Kindly mark this as the accepted answer if it helps.
I've put together an example here using the Atlas template.
The goal is to create an association between Entity (I left it with this name to be generic. It could be Account or another entity) and AtlasCountry, but ordering the selected items to the top of the list.
First, you have to use a DataView of the Entity. Here we can pass it as page context, but for didactic purposes, I created a Microflow DS_Entity.
DataView settings we will have a microflow DS_AtlasCountry_Sorted to retrieve the AtlasCountries. Note the association in blue.
The DS_AtlasCountry_Sorted microflow will have a trick:
With this, you will have the selected values at the top of the list and then the rest of the database.
Now the biggest trick is to make this microflow be called every time a value is selected. This is simple. In the Events tab of the combo box, select the On change action option to call a nanoflow (it has to be a nanoflow) that will be called every time there are changes in the combo box.
This nanoflow will simply refresh the Entity. This forces the combo box widget to be rendered every time there are changes. This in turn will call the DS_AtlasCountry_Sorted microflow.
The results:
Lenny,
I created a small example.
Here is my domain model:
I thne created a page to populate both Product and Country entities.
The Product_NewEdit page looks like this:
The Combo Box uses a Datasource Microflow that looks like this:
The Combo Box is Events tab looks like this:
This works as you described. You may want to change the Combo Box Events tab so that it does not save changes when you select countries. You should see how you want this to behave.
Hope that helps,
Mike