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.
-
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– David HartmanCommented 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?– kapitanemmanCommented Feb 23, 2017 at 4:49
Add a comment
|
1 Answer
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);
});