Logo 
Search:

Sharepoint 2010 Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint 2010       RSS Feeds

Hide Web Part in SharePoint 2010

  Date: Oct 13    Category: Sharepoint 2010    Views: 1975

I am using the script below in a CEWP in MOSS to
hide empty list/library web parts, but it doesn't work when added as html to a
CEWP in SharePoint 2010. I've tried several other methods without success in
2010. Does anybody have any ideas for hiding empty web parts in 2010? Thanks.

Script used in 2007 (Test List=WP Name):

<script>
function HideWebPartWithZeroRows()
{

var a = document.getElementsByTagName("TABLE")
for (var i=0;i<a.length;i++)
{
if (a[i].summary=="Test List")
{
if (a[i].rows.length==1)
{
[i].parentNode.parentNode.parentNode.parentNode.parentNode
var x =
a[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNod\
e.parentNode.parentNode

x.style.display="none";
}
}
}

}

_spBodyOnLoadFunctionNames.push("HideWebPartWithZeroRows")

</script>

Share: 

 

1 Answer Found

 
Answer #1    Answered On: Oct 13    

Sounds like you need to crack open the View Source view and find out what
the WebPart HTML looks like these days :) Duty calls at the moment, but I
may be able to take a look later.

 
Didn't find what you were looking for? Find more on Hide Web Part in SharePoint 2010 Or get search suggestion and latest updates.




Tagged: