Monday, July 27, 2009

Hiding the view selection in a SharePoint list




I have to hide the List View selection box on the top right hand corner in one of the SharePoint lists that I created. It is to avoid users changing any pre-defined settings and seeing other people's views.

For example, in a leave form list, you should only see your own leaves but not your managers view which contains other people's leaves.

To do that, apply the following Javascript onto your list view:
function hideViewMenu() {
var TDs = document.getElementsByTagName("TD");
for (var i=0; i<TDs.length; i++) {
if (TDs[i].className == "ms-listheaderlabel") {
var tableNode = TDs[i].parentNode;
tableNode.style.display = 'none';
break;
}
}
}

No comments:

Post a Comment