Forum Discussion
Modifying grouped list headers
- Feb 19, 2017
I love the coding solutions, they are great.
Love it! Loading a 90 KB jQuery library to do something.Here is your grouped header HTML:
since that <span> has a display inline style, you can't overrule it with display:none
But one line of CSS can hide it:
``
span[style*='lighter'] {color: transparent;}``
Put it in a CEWP on the ListView page, between <style> tags
But coding solutions are great, they really are!
Your second requirement requires scripting because you want to move DOM elements. You want to move the label inside the A tag
![]()
But no need for jQuery, vanilla JavaScript can do that:
var groupedAs=document.querySelectorAll("tbody[id^='titl'] a"); //iterate Nodelist as Array [].forEach.call( groupedAs , function(A) { if(A.nextSibling){ // change this DOM element once when there is a label A.firstChild.nextSibling.remove(); // remove fieldname label var value=A.appendChild(A.nextSibling); // move label inside A tag value.nodeValue=value.nodeValue.split(' : ')[1]; // remove colon A.nextElementSibling.remove(); // remove counter after A } else { console.warn('ran code twice') } });
Thank you for your response, but I'm a novice, and I'm not sure what you're saying. My plan was to add a CEWP to the page where I've added the list web part (or should I use a Script Editor web part?), is there something I should add to this code, as referenced in the link I posted? I do NOT want to modify the master page.
Use below script in CEWP, remember to refer jquery library.
$("table.ms-listviewtable td[class=’ms-gb’]").each(function() {
//Hide all Counts for Groups
$(this).find("span:last").remove();
});
I love the coding solutions, they are great.
Love it! Loading a 90 KB jQuery library to do something.
Here is your grouped header HTML:
since that <span> has a display inline style, you can't overrule it with display:none
But one line of CSS can hide it:
``
``
Put it in a CEWP on the ListView page, between <style> tags
But coding solutions are great, they really are!
Your second requirement requires scripting because you want to move DOM elements. You want to move the label inside the A tag
![]()
But no need for jQuery, vanilla JavaScript can do that:
var groupedAs=document.querySelectorAll("tbody[id^='titl'] a"); //iterate Nodelist as Array [].forEach.call( groupedAs , function(A) { if(A.nextSibling){ // change this DOM element once when there is a label A.firstChild.nextSibling.remove(); // remove fieldname label var value=A.appendChild(A.nextSibling); // move label inside A tag value.nodeValue=value.nodeValue.split(' : ')[1]; // remove colon A.nextElementSibling.remove(); // remove counter after A } else { console.warn('ran code twice') } });
- Allison RizakFeb 27, 2017Brass Contributor
I was able to apply the css to hide the item counters, worked great - thanks!
No idea what to do with the rest of what you said, but I'm happy with just hiding the numbers.