Friday, August 21, 2009

How to hide view selector in list view webpart ?

I am working on an initiative where I have to present multiple views of a sharepoint list, these views have sensitive information in certain columns that cannot be shared among other views of the same list. Here the idea is create unique views for each group of users with their sensitive columns and then not allowing the users to switch to each others view, point to note is all of these views are public views.

I was scratching my head figuring out a solution to restrict the view selection from pages that are generated for each views. My theory was there has to be a way to handle the view selector ?? I opened sharepoint designer to see if I can figure this out. I opened one of the existing view page for a list (AllItems.aspx) and then was looking for some kind of view selector control in the list webpart that was displayed. It took me few hours to figure out that only converting the list view webpart to the XSLT dataview will generate a selector control in the XSLT code, something like the line of code below.

<sharepoint:viewselectormenu runat="server" visible="false"”> </sharepoint:viewselectormenu”>


The line of code is the view selector control that is responsible to cause the switch, I simply added the visible attribute setting it to false to make the control unswitchable.

Other way would be to completely get rid of the control to give a clean user experience. It took few hours for me figure this out, but I am hoping this will help somebody do this quickly in this amazing world of sharepoint.

1 comment:

  1. Add Content Edtior Web Part

    < style >
    .ms-listheaderlabel {display: none;}
    .ms-viewselector {display: none;}
    < /style >

    --fix the style tag .. I had to add spaces to get comment to accept it.

    j6424

    ReplyDelete