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"
                                    }
                                ]
                            }
                        }
                    },

Like 0

Like

Share

0 comments
Show all comments