Question

Freedom UI - Sorting Lookup

By default, lookups are sorted on Name.



I have a lookup on a freedom UI page that I instead want to sort (ascending) based on an integer field on the lookup called "Order".



I can see "LookupAttribute_xxxx_List_Sorting" attributes within the page when debugging, I'm assuming these can be used to order the lookups but I'm not sure what data the attribute expects.



Thanks for any assistance!

Like 1

Like

6 comments
Best reply

After a year or so I decided to have another look at this and have managed to get it working via code.
 

For example, adding this handler on the Accounts_FormPage should filter the "Type" by "Id" descending.


(In the code block change the ">" to ">", can't seem to fix this in the reply editor)

 

{
	request: "crt.HandleViewModelInitRequest",
	handler: async (request, next) => {
		let sortingConfigList = await request.$context.Type_List_Sorting;
		let firstSortingConfig = sortingConfigList[0];
		firstSortingConfig.columnName = "Id";
		firstSortingConfig.direction = "desc"; //desc or asc
		return next?.handle(request);
	}
}

 

 

 

 

So the page context attribute we need to change is attributecode_List_Sorting.
This is a list of "order configurations" (so you can order by multiple columns for example)
So we just need to get the first item in this list and change the columnName from Name to whatever other field we need to order on
And we can optionally change the direction property to "desc" to order descending (it is "asc" by default).

The logic of the combobox is developed in the way that when the page os loaded the metadata for the combobox is generated additionally and it ignores custom sorting and always adds default sorting. I will notify the product owner about your question in the community so that the possibility of custom sorting could be developed and added in Fredom UI out-of-the-box. Thank you for helping us in making the app better!

Oleg Drobina,

Hello, is it available for Freedom UI current version?

This is definitely something we'd be interested in being able to do too. It was possible in Classic UI.

Any info on whether this is now possible in Freedom UI?

After a year or so I decided to have another look at this and have managed to get it working via code.
 

For example, adding this handler on the Accounts_FormPage should filter the "Type" by "Id" descending.


(In the code block change the ">" to ">", can't seem to fix this in the reply editor)

 

{
	request: "crt.HandleViewModelInitRequest",
	handler: async (request, next) => {
		let sortingConfigList = await request.$context.Type_List_Sorting;
		let firstSortingConfig = sortingConfigList[0];
		firstSortingConfig.columnName = "Id";
		firstSortingConfig.direction = "desc"; //desc or asc
		return next?.handle(request);
	}
}

 

 

 

 

So the page context attribute we need to change is attributecode_List_Sorting.
This is a list of "order configurations" (so you can order by multiple columns for example)
So we just need to get the first item in this list and change the columnName from Name to whatever other field we need to order on
And we can optionally change the direction property to "desc" to order descending (it is "asc" by default).

John Kingsbury,

That's excellent news. Thanks for sharing. 

Ryan

Show all comments