Pages

Thursday, January 27, 2011

Removing Link from People Name in Sharepoint List

Sharepoint lists can have special type of  column that refers to a person or group. When viewing the list data the person column will display the person name and picture with a  link to the page that displays the user details(userdisp.aspx). Sometimes it would be desirable to prevent users from viewing the user details.  This can be done by using few lines of Jquery script. Following steps explains the steps involved
1. Navigate to the Sharepoint page that displays the list with the people link
2. The people column will be displayed like the one shown below
Peoples column with link
3.  Add a content editor webpart to the page
4. Modify the content editor webpart and go to the source editor and add the below script
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>  
<script>
$(document).ready(function () {
    $('a[href*=userdisp.aspx]').each(function(idx, item) { 
$(this).attr({href:location.href+"#",onClick:"return false;"})
var content = $(this).html();
$(this).parent().html(content)
    });
});    
</script>
5. Now the people column will be displayed like the one shown below
Peoples column without link