How to implement field sort using html?
We have a drop down list of relevancy and date sort on front end. We bind these items in html. Please find the example below.
<select> <option class="enabled state-selected CoveoSort slected-value coveo-selected" data-sort-criteria="relevancy"/> <option id="sort-by-date" class="enabled state-selected CoveoSort slected-value coveo-selected" data-sort-criteria="datesort"/> </select>
We want the Relevancy and date sort of coveo should fire on selection of dropdown. For relevancy, we use the default coveo relevancy sort. For date sort we are using our custom fields.
We have changed the data-sort-criteria of date sort using script like below.
var computedDateFieldName = CoveoForSitecore.Context.fields.toCoveo('@@ComputedDate'); computedDateFieldName = computedDateFieldName + " descending";
We are using coveo 4.0 for sitecore. We have tried many workarounds. Could anyone please suggest how to sort through script on change of dropdown?
I have resolved this using sort criteria:"@computedfield ascending" in query.