0

is there a way to get the count of items in a Grouped View via Javascript? The grouped view already has a count, but want to pass along that count to another object (a chart) and can't get past the list items.

2
  • are you trying to pass the count of items to a chart on the same page as the list? If so you could target through jquery the element that contains the Group View count. If you're trying to pull the Grouped View count from a different page, just make a REST call to the list and use the $filter attribute passing in the values that make the Grouped View unique. This last one is assuming you are using at least SharePoint 2013 Feb 23, 2017 at 3:12
  • Hi David, yes I'm trying to pass count of grouped items to a chart on the same page. There is a count on the group header but I cannot find the correct notation to pass those numbers. It seems when the group is collapsed, there really is no number there? Feb 23, 2017 at 4:49

1 Answer 1

0

You could go CSR/JSLink and count before the HTML is displayed

Or once the page has loaded analyze the HTML

[].map.call(
  document.querySelectorAll("tbody[id^='titl']")
  ,function(body){
    console.log(body.innerText);
    var span=body.querySelector("span[style*='lighter']")
    var label=span.innerHTML;
    var value=Number(label.split('')[1]);
    console.info(value);
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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