Sorting dropdowns, lookups, lists, and quick filters in Freedom UI.
A number of folks in the community have asked about filtering various lists in Freedom UI, particularly, dropdowns, quick filters, lookups, etc. There are a few solutions out that propose using handlers and etc but a much simpler and reliable method can be deployed directly through your viewModelConfig diff.
You can sort any/all Freedom UI lists from the viewModelConfig very easily, no handler needed. Simply find whatever lookup DS you want to sort, create a copy with “_List” appended as a new entry in ViewModelConfig, then set your default sorting. With this approach, you can sort pretty much any/all lists, including quick filters.
The below example is as of version 8.2.1. Not sure whether this works on older versions of Freedom UI, but I would assume anything >8.1.
“PDS_YourLookup”: { // This is the existing lookup dropdown that we want to filter “modelConfig”: { “path”: “PDS.YourLookup” } }, “PDS_YourLookup_List”: { // Create a new attribute for our _List “modelConfig”: { “sortingConfig”: { “default”: [ { “columnName”: “Name”, // Replace with the actual object code to sort by “direction”: “desc” // or “asc” for descending order } ] } } }
Here's a real-life example that many will benefit from: sorting months! Alphabetically, the sort for months results in each month getting completely thrown out of order. Alphabetical is particularly a nuisance for a use case like this because the order also follows by character order. Even if you tried to use 1 - Jan, 2, Feb -- the alphabetical sort would actually sort as 1 - Jan, 11 - Nov, 12, Dec, 2 - Feb, etc... So even this doesn't work! You'd need to expand further and use 01 - Jan, 02 - Feb, etc. Instead, we can add a column to our "month" lookup for the month integer value, then sort on this new integer value.
Adding an integer column with this sorting methodology enables you to simply display the month name without any arbitrary leading characters 01 - Jan, 02 - Feb, etc.
Here I am sorting months for a fiscal year end dropdown by an additional object column. In this case, I've added "MonthInt" as an integer column to this object and set the values 1-12 accordingly.
In my viewModelConfig diff, I have the following entry created automatically by simply adding my lookup to the page:
"CreditCardAppDS_FiscalYearEnd": {
"modelConfig": {
"path": "CreditCardAppDS.FiscalYearEnd"
}
},
I use the method above to add a new merge for my adjustments to the default sort on the hidden _List attribute, so my combined viewModelConfig for this element looks like this:
"CreditCardAppDS_FiscalYearEnd": {
"modelConfig": {
"path": "CreditCardAppDS.FiscalYearEnd"
}
},
"CreditCardAppDS_FiscalYearEnd_List": {
"modelConfig": {
"sortingConfig": {
"default": [
{
"columnName": "MonthInt",
"direction": "asc"
}
]
}
}
},
Would be so nice if Creatio could expose this in the Page Designer UI! Thanks for the info, very useful.
Hi Matthew, great article!
However, I'm trying to apply the same sorting to a QuickFilter of type lookup on a list page and haven't been able to get it working.
Has anyone managed to sort a QuickFilter lookup list? Is there a different request type or a different property name that controls sorting for this specific datasource?
Thanks!
Valerie Bsereni,
You are right -- I made an assumption that the quick-filter lookup lists would follow the same format but after digging in further, these seem to follow an entirely different structure. I spent a few hours experimenting on various adjustments trying to get the quick filter lists to comply but I haven't had any luck at all.
Possibly this could be done through a handler but all my attempts to manipulate the viewModelConfig sources directly were futile.
As of now, I'm still stumped. Will follow-up if I can find something.
Thank you for the update and for putting so much time into looking into this. I really appreciate the effort. I’m also going to keep digging on my end, and if I manage to find a workaround or get it working, I’ll be sure to let you know right away