2

I added a custom search result page, which offers custom refinement options. One of these options include refinement by matching a Choice (Yes/No) field. The refinement is using the default Refinement Item template, and looks like this:

enter image description here

As you can see, the mapped property's values (Yes/No) are displayed in binary. Is there a way of displaying Yes and No instead of 1 and 0? Or even better - Online and Offline?

  • I don't think that's "binary" - it is probably the value of SQL Server's bit data type field for this data. – tnktnk Mar 10 '14 at 13:37
  • 1
    Clearly, but how can I map these fields to Strings? (Online/Offline) – doque Mar 10 '14 at 13:48
0

I do not think its possible with OOB implementation. You will have to do small customization in Refinement Display Template.

Open your site in SharePoint Designer (Or whatever editor you like to open display templates), go to Master Pages > Display Templates > Filters. Copy "Filter_Default.html" and open to add some custom code.

You will need following code to be added in function outputFilter.

var origOnlineOffline = refinementName;
var formattedOnlineOffline = '';
// Sometimes get an "All" setting in order to remove the refiner,
// so need to leave this alone.
if (origOnlineOffline == 'All') {
    formattedOnlineOffline = origOnlineOffline;
}
else {
    new Boolean(refinementName);
    formattedOnlineOffline = origOnlineOffline == 1 ? 'Online' : 'Offline';
}

And following line of change in HTML Div

<div id='RefinementName' class='_#= nameClass =#_'> _#= $htmlEncode(formattedOnlineOffline) =#_ </div>

After saving the new display template, return to search page, edited the page, and edit the Refiners webpart. After selecting the refiner you want to change, choose new display template (the one you created above).

I have referred The Story of the Boolean Search Refiner. I recommend you to read this blog, Nice one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.