2
(function () {      
var itemCtx = {};
itemCtx.Templates = {};
itemCtx.Templates.Group = GroupOverride;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
})();
function GroupOverride(Ctx, group, groupId, listItem, listSchema, level, expand) {    
return '<div style="font-weight:bold; display: inline-block;">' + listItem[group] + ' ::'  + '<div><ul>'+ listItem[group].Count + '</ul></div>' + '</div>';    
}

I have a list column name "category" and have values like Completed, Not Completed, Started.

I want to group list items based on category. I want to format it without showing all the list items so that it should look like:

Completed : 45
Not Completed : 30
Started : 20

By using above code, I am able to show category names but not the count (listItem[group].Count is throwing error)

Completed : 
Not Completed :
Started : 
1

You can find the count using

function GroupOverride(Ctx, group, groupId, listItem, listSchema, level, expand) {
    var html  = '<div style="font-weight:bold; display: inline-block;">';
        html += listItem[group] + ' :: <div>';
        html += '<ul>'+ listItem[group + ".COUNT.group"] + '</ul></div></div>';

    return html;
}

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.