donderdag 13 september 2012

Hide a webpart or Columns of a ListView webpart.


Found some interesting JQuery for hiding a SharePoint Webpart, 
or some columns of a ListviewWebpart.
This can be usefull if you have some columns that are language depentend. 
So of that moment you can hide for example a column with dutch text 
or an other column with other information. 
Or if you want that someone has less columns than another user 
in the same view and you don't want to duplicate the views. 

My example below will hide a complete webpart and the first three columns 
of a ListView webpart.
Attention, if you have more than one listView webpart on your page, 
all the same columns will be hidden.

If you know how I can determ to hide the columns of a specific webpart... 
I'm interested in the code.


$( document ).ready( function() {
 // hide new webpart
 $(MSOZoneCell_WebPartWPQ5).hide();
 // hide column 1, 2 and 3           
    $(".ms-listviewtable,.ms-emptyView").find("td:nth-child(1),th:nth-child(1)").hide();     
    $(".ms-listviewtable,.ms-emptyView").find("td:nth-child(2),th:nth-child(2)").hide();     
 $(".ms-listviewtable,.ms-emptyView").find("td:nth-child(3),th:nth-child(3)").hide();      
});


 

Geen opmerkingen:

Een reactie posten