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') } });
SharePoint online
Hi Allison,
Just to add, please make sure the Javascript code is added in a CEWP web part which is placed below the List View web part. Because Javascript runs sequentially down the page and hasn't been called through a function, it might not take effect if it doesn't find the particular html element.
Also if you end up using JQuery, to be safe, you could call the iterator function in $(document).ready() function to make sure all your page elements are initialized when the hide function is called.
Also, there are smarter CSS ways to achieve the same but considering that this is a OOB list view there might be some side effects if the CSS is not properly structured.
Thanks,
Asish