Friday, November 4, 2011

Remove Lookup Hyperlink from SharePoint List view using JQuery

When you use lookup to the list automatically SharePoint give link to the lookup item on list view.
Check it out….
Lookup column with Hyperlinks
But many times, we don’t want  those Hyperlinks on the list view, as we can remove it from SharePoint Designer but it’s a hectic task.
Simply add JQuery  to remove those Hyperlinks.
First, get the URL of the link using Developer tool of IE or Firebug of Firefox browser. we are going to some part of URL in the below code.

Get URL using Developer tool of IE


Then copy following JQuery code to the HTML form WebPart on list view.

Jquery For MOSS 2007/WSS 3.0:


    
    

Note: Change highlighted text as per your context.
Jquery For SharePoint 2010/SharePoint Foundation 2010:





Note: Change highlighted text as per your context.

If View is Grouped, set list view setting "By default, show groupings:" to  Expanded


List View setting: Make sure that By default, show groupings: Expanded

List view with removed hyperlinks to Lookup columns:

Live simple!

8 comments:

  1. Hello, Amit!

    Thank you SO Much for the post on removing URLs in lookup fields. This option allows users more flexibility than other codes I’ve seen!

    I have a quick question… Is it possible to get this code to work on webparts that have groupings? It seems to be workign fine in a standard list, but once groupings are added the links appear. Do you have any suggestions?

    Thanks!!!

    ReplyDelete
  2. Hi Rudy,

    You can use following function for Grouped View.

    function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {
    }
    As ExpGroupRenderData overwrites the default SharePoint function. This function is needed for collapsed groupings.

    I have also updated the post.

    ReplyDelete
  3. Thanks, Amit. This added script seems to remove all documents or items in the grouped list. I know they are there because the count is working, but the rows with the docs and items are gone.

    Any ideas?

    Rudy

    ReplyDelete
  4. Hi Rudy,
    I have updated the post for SharePoint 2010 Group View.
    Please check and let me the results.

    ReplyDelete
  5. the last item Hyperlink is not removed .My view is grouped so I used
    function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {
    Removelink(); // Call to Removelink function on Page Load
    }

    Any Idea

    ReplyDelete
  6. Hi Anshul,
    I have updated the post for the same.

    ReplyDelete
  7. hi amit,

    u posted good one
    but coming to my self i want to hide the hyper links in list view / display form.

    i am using your code it working fine for a field containing single value with hyper ink.

    but for multiple values it not working.

    ReplyDelete
  8. Really a good one but not working when we move on Paging from one page to another
    gans

    ReplyDelete