Gravatar for jlynch@sonusnet.com

Question by Jim Lynch, Jul 20, 2016 6:17 PM

Allow facet to be toggled for ascending and descending

From a VisualForce page, I want to give the user the ability to toggle a facet in alpha ascending or descending order. I know I can sort in ascending order with the following div:

But how can I allow the order to be toggled between ascending and descending ?

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Jul 20, 2016 6:21 PM

Further I also added the following:

data-available-sorts="occurrences,score,alphaAscending,alphaDescending"

but don't see ascending or descending enabled.

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Jul 22, 2016 12:43 PM

Anyone have any ideas ?

2 Replies
Gravatar for gminero@coveo.com

Answer by gminero, Aug 2, 2016 2:53 PM

Root cause was in the Visualforce Page, there was a script tag configuring the ValueCaption:

var myValueCaption = {  "txt": "Text files" };
 $("#search").coveo("init", {
    Facet: {
        valueCaption: myValueCaption
    }
 })

Our documentation https://developers.coveo.com/display/public/JsSearchV1/Facet+Component states the following: "Using the valueCaption option disables sort by alpha."

We should probably include this in the facet component documentation as well

Gravatar for slangevin@coveo.com

Answer by Simon, Jul 28, 2016 10:28 AM

The data-available-sort attribute is the right thing to use, but do you have the settings enabled?

https://developers.coveo.com/display/public/JsSearchV1/Facet+Component#FacetComponent-enableSettings

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Jul 28, 2016 2:40 PM

The default for data-enable-settings is "true" though I did explicitly set it. Here is the div:

    <div class="CoveoFacet" data-title="Wiki Space" data-field="@syscfspacename" data-enable-settings="true" data-available-sorts="alphaAscending, alphaDescending,occurrences,score" data-tab="All, Confluence"></div>
Gravatar for slangevin@coveo.com

Comment by Simon, Jul 28, 2016 2:47 PM

You are indeed doing it correctly. You can see a working example here: https://search.coveo.com/#sort=relevancy&f:languageFacet=[English] and it seems to be set the same way you did. Do you have access to support? I would suggest opening a support case. It might be something in the configuration of your Visual Force page conflicting with our controls.

Ask a question