Gravatar for

Question by chmassie, Jan 14, 2016 10:36 AM

Coveo for Sitecore How to display grouped results

I have a page where a client wants to display all the products in a category, and group the results by type. I'm using a groupByRequest property on the queryBuilder in JS like this (also note that we're using MVC, in case that matters):

.on("buildingQuery", function(e, args) {
    //args.queryBuilder.sortCriteria = "FieldAscending";
    args.queryBuilder.groupByRequests = [{ "field": "@Model.ToCoveoFieldName("fieldname")", "sortCriteria":"AlphaAscending" }];

My results come back looking like the linked image (with some stuff blurred to protect the innocent).

Grouped Results

Here's the handlebars markup I have so far to display the results:

Handlebars Markup

This markup works fine to just display all of the results. What I need to do is modify it so that for each group, I can output some markup that allows me to label the group, i.e.: wrap the result in that group in a surrounding div with some text, styling, etc.

How can I accomplish this?

Gravatar for

Comment by chmassie, Jan 14, 2016 1:00 PM

It might be useful for me to mention that the field I'm grouping on is not a parent of the results, per se, but rather just a common attribute on each result item. In that regard, I'm not sure that the Folder Component is the right direction to solve my problem.

Gravatar for

Comment by ncipollina, Jul 8, 2016 9:10 AM

Did you ever receive and answer to this question? I am trying to do the same thing at my client.

0 Reply
Ask a question