This time soon enough, I really wanted to complete my thoughts on Coveo sorting. We so far learnt two main things from the previous posts. How to accomplish Coveo Sorting on a typical custom coveo rendering on a sortable field and how to make sorting work when you have Coveo Tabs that list the results out.
Next step, we will learn how we can achieve the same on Java script, there are few situations where this would come in handy. In my example, what I was trying to do is apply Coveo Sorting on a computed field. We are all aware that a computed field is in memory and hence we do not have a GUID we could use to work around the active issue which was present on adding default sort order to Custom Coveo rendering. With out GUID, the sorting will not work on the rendering due to the issue, this would not be a problem if you are using latest version of Coveo, but, in our case we had no option, but, to battle this challenge.
Below are few resources that helped me get started.
Below is the code snippet that I plugged in my Custom Coveo View which needed the default sort order to be set
Do note that you have to set this in function, so, the properties get set properly and applied on XHR request. Mission accomplished.
Now, I covered all the ways that we applied Coveo sorting on different style components. Another cool thing I noticed if it helps some one is that even if your field is of type Date, do not use that option for Default Sort Order. Just use Field as your type and all is working as expected.
Happy Problem Solving people. Enjoy your rest of the weekend! I am actually blogging from SF airport after hogging on organic veggie quesadilla. 😉