Gravatar for saibalini.ray0@gmail.com

Question by saibalini, Apr 1, 2019 4:30 AM

How to implement field sort using html?

Hi,

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?

1 Reply
Gravatar for saibalini.ray0@gmail.com

Answer by saibalini, Apr 5, 2019 10:38 AM

Hi,

I have resolved this using sort criteria:"@computedfield ascending" in query.

Ask a question