Remove group headings
Summary: when grouping a library the column that is selected for grouping displays before each header. Use remove group headings to only show the columns values.
Instructions:
- Copy and paste this script into a txt file: (ex: notepad)
<script type=”text/javascript” language=”javascript”>
_spBodyOnLoadFunctionNames.push(“HideHeaders”);
function HideHeaders() {
var elements = getElementsByClassName(document, “td”, “ms-gb”);
var elem;
for (var i = 0; i < elements.length; i++) {
elem = elements[i];
elem.childNodes[3].style.display = “none”;
elem.childNodes[4].nodeValue = elem.childNodes[4].nodeValue.replace(‘:’, ”);
}
elements = getElementsByClassName(document, “td”, “ms-gb2”);
for (var i = 0; i < elements.length; i++) {
elem = elements[i];
elem.childNodes[3].style.display = “none”;
elem.childNodes[4].nodeValue = elem.childNodes[4].nodeValue.replace(‘:’, ”);
}
}
function getElementsByClassName(oElm, strTagName, strClassName) {
var arrElements = (strTagName == “*” && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, “\\-“);
var oRegExp = new RegExp(“(^|\\s)” + strClassName + “(\\s|$)”);
var oElement;
for (var i = 0; i < arrElements.length; i++) {
oElement = arrElements[i];
if (oRegExp.test(oElement.className)) {
arrReturnElements.push(oElement);
}
}
return (arrReturnElements)
}
</script>
<script type=”text/javascript” language=”javascript”>
_spBodyOnLoadFunctionNames.push(“HideHeaders”);
function HideHeaders() {
var elements = getElementsByClassName(document, “td”, “ms-gb”);
var elem;
for (var i = 0; i < elements.length; i++) {
elem = elements[i];
elem.childNodes[0].childNodes[1].nodeValue = “”;
elem.childNodes[1].nodeValue = elem.childNodes[1].nodeValue.replace(‘:’, ”);
}
elements = getElementsByClassName(document, “td”, “ms-gb2”);
for (var i = 0; i < elements.length; i++) {
elem = elements[i];
elem.childNodes[1].childNodes[1].nodeValue = “”; elem.childNodes[2].nodeValue = elem.childNodes[2].nodeValue.replace(‘:’, ”);
}
}
function getElementsByClassName(oElm, strTagName, strClassName) {
var arrElements = (strTagName == “*” && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, “\\-“);
var oRegExp = new RegExp(“(^|\\s)” + strClassName + “(\\s|$)”);
var oElement;
for (var i = 0; i < arrElements.length; i++) {
oElement = arrElements[i];
if (oRegExp.test(oElement.className)) {
arrReturnElements.push(oElement);
}
}
return (arrReturnElements)
}
</script>Disclaimer: I did not write this script; it is from here: Bistesh Jois’s blog. - Save the file at site collection level / top level site. I like to use the site collection documents library – this clearly identifies the content in there as documents used across the site
- Navigate to the library/ webpage that is displaying with groupings
- Edit the page
- Top right hand corner of the page, select the settings cog then edit page
- Add a content editor web part to the page
- Select Add a web part, in the Media and content folder, select content editor
- Edit the web part
- Select the dropdown arrow to the right of the web part ribbon, then select edit web part
- In the webpart editor window on the right side of the page
- Paste the url to the text file at the top, in the content link box
- Under the appearance section, update the title to Remove Group Headings and change the chrome type to none. This will make the web part ribbon not display
- The groups should now display with the values only – without the column name.