Get Free Trial

How to display the values in the filter in a custom order?

Akshay Alva asked on January 11, 2022

Just a follow-up question regarding the display of values in the filter. Currently, the values are listed in alphabetical order. We have a requirement for one of the filters to display the values in a custom order (based on the most frequently used values.. assuming each value has a weight assigned, we would fix a higher weightage for certain values which always show at the top). 
Can you please recommend the best way to achieve this functionality?
Warm Regards,

Tetiana Lebiga created this ticket from #43502

1 answer

Maksym Diachenko Maksym Diachenko Flexmonster January 11, 2022

Hi, Akshay!
Thank you for your question.
There are two ways you can implement custom sorting in Flexmonster:
1. You can specify sortOrder property with values in an order predefined by you.

rows: [ 
          uniqueName: "Category", 
          sortOrder: ["Bikes", "Cars", "Clothing", 
               "Accessories", "Components"] 

2. You can set a sorting function with sortingMethod API call.

flexmonster.sortingMethod("Category", function (a, b) { 
    return a < b ? 1 : -1; 

Please refer to our documentation for more details on custom sorting:
We hope it helps. Please let us know if any questions arise.
Best Regards,

Please login or Register to Submit Answer