none
Display Lookup Column NOT as link? RRS feed

  • Question

  • I have a column in List B that looks up its value from the Title column is List B. When I display this column in a List A view, it displays the value as a hyperlink to that particular item in List B. How can I include this column in a view in List A without having it be a hyperlink back to List B? 

    Thanks!

    Friday, July 22, 2011 3:13 PM

Answers

  • If you allow one value only, you can do it like this:
    In SPD, highlight one of the links (lookup values), right-click and select Edit Formula from the pop-up menu. You will see a dialog with a formula like this in the right side: $thisNode/@*[name()=current()/@Name]
    Delete this one.
    In the left side, you will see a list of columns (under Rows) in the tree. One of them is your lookup column and after it is the same column with a dot after it. Double-click this one.
    Your formula will be replaced (right side) with: $thisNode/@your-lookup-column.
    Change it to: substring-after($thisNode/@your-lookup-column.,'#')
    Click OK and save the view.
    AK
    • Marked as answer by Lily Wu Saturday, July 30, 2011 1:42 PM
    Saturday, July 23, 2011 6:18 AM

All replies

  • OOB its not possible for lookup column there is 2 way to achieve this 

    either you can create your own lookfield control to change the display or

    create your own display form to disable hyperlink

    or

    add some javascript in js file

    function FixedActionLinkWidth() {

            var objImg = document.getElementsByTagName("IMG");

            for (var i = 0; i < objImg.length; i++) {

                var imgSRC = objImg[i].getAttribute("src");

                if (imgSRC == "/_layouts/images/hhome.png") {

                    var objAnchor = objImg[i].parentNode;

                    if (objAnchor != null) {

                        if (objAnchor != 'undefined') {

                             //add your custom logic to disable or remove hyper link

     

                            }

                        }

                    }

                }

            }

        }

     

        _spBodyOnLoadFunctionNames.push("FixedActionLinkWidth");


    Rahul Sharma -------------------------- Coding is all about passion !!!!!!
    Friday, July 22, 2011 3:36 PM
  • You can modify the xsltlistview in SharePoint Designer. Select the column name with a dot (.) at the end. If you allow multiple values, you'll see numbers and the # sign and can either remove them in xsl or add a template to strip html from the original (linked) field.
    AK
    Friday, July 22, 2011 3:37 PM
  • Hi,

    I've written a blog about it, it's easy to change in a view in SP Designer

    http://aleemsheikh.wordpress.com/2011/07/08/remove-hyperlink-from-lookup-column-in-sharepoint/

     


    Aleem Sheikh | SharePoint Architect/Developer | MCPD(SP 2010), MCTS(MOSS 2007), MCAD(.Net), MCSD(VS 6) | London, United Kingdom
    Friday, July 22, 2011 4:10 PM
  • If you also look at some of the new features in Workflows, you can parse out.  You can extract text from almost anything you have in a field.

    • Extract substring from end of string
    • Extact substring from index of string (aaray)
    • Extract substring from start of string
    • extract substring of string from index with length.

    Here is a blog post on this very topic, showing how to do this.

    http://sharepointresourcecenter.com/sharepoint-2010-workflow-actions-string-manipulation.html

    Good luck,

    Gary

    blog www.sharepoint2010now.com

     


    Gary Newman MCSE, MCT, CCNA MCDBA, MCAD, MCSA MCTS SharePoint 2007 Dev & Admin MCPD SharePoint 2010 Development My Blog www.sharepoint2010now.com
    Friday, July 22, 2011 4:42 PM
  • Hi,

    I've written a blog about it, it's easy to change in a view in SP Designer

    http://aleemsheikh.wordpress.com/2011/07/08/remove-hyperlink-from-lookup-column-in-sharepoint/

     


    Aleem Sheikh | SharePoint Architect/Developer | MCPD(SP 2010), MCTS(MOSS 2007), MCAD(.Net), MCSD(VS 6) | London, United Kingdom


    Hi Aleem. Your approach looked the most straighforward to an amateur such as myself. Unfortunately, when I open the page in SP Designer, I do not see the "xsl:value-of" property. Am I missing something obvious?

    Thanks!

    Friday, July 22, 2011 7:50 PM
  • If you allow one value only, you can do it like this:
    In SPD, highlight one of the links (lookup values), right-click and select Edit Formula from the pop-up menu. You will see a dialog with a formula like this in the right side: $thisNode/@*[name()=current()/@Name]
    Delete this one.
    In the left side, you will see a list of columns (under Rows) in the tree. One of them is your lookup column and after it is the same column with a dot after it. Double-click this one.
    Your formula will be replaced (right side) with: $thisNode/@your-lookup-column.
    Change it to: substring-after($thisNode/@your-lookup-column.,'#')
    Click OK and save the view.
    AK
    • Marked as answer by Lily Wu Saturday, July 30, 2011 1:42 PM
    Saturday, July 23, 2011 6:18 AM
  • Saturday, July 23, 2011 6:39 AM
  • Hi,

    click on any cell in the column, and it will set the cursor in the beginning of the text, then click on text of the cell, and the text will be selected and enclosed in a gray box, then you will see xsl:value-of.

    hope it works for you.


    Aleem Sheikh | SharePoint Architect/Developer | MCPD(SP 2010), MCTS(MOSS 2007), MCAD(.Net), MCSD(VS 6) | London, United Kingdom
    Monday, July 25, 2011 9:06 AM
  • Hi Aleem. I'm getting closer, but not quite there yet. :-)

    If I try to edit the field in a view on a web part on the default.aspx page, I don't see the xsl:value-of tag. However, if I open up one of the list views such as All Items and then try to edit the field, I do have the xsl:value-of tag.

    Next problem, I am getting an "invalid HTML" error message when I edit the tag. I am replacing this:

    <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes">

    With this:


    <xsl:value-of select=”substring-before(substring-after($thisNode/@*[name()=current()/@Name],’>’), ‘&lt;’)” disable-output-escaping=”yes”>

     

    Where am I messing up?

    Thanks!

    Saturday, July 30, 2011 6:54 PM
  • Hi Sorry for the confusion here, you need to replace '>' with '&gt;', I have now changed it on my blog as well.

    The same should work on the home page if you have added the list as a web part, but for that you will have to detach the page from the layout and open it in advance mode and then you will be able to apply the same technique in page design mode.


    Aleem Sheikh | SharePoint Architect/Developer | MCPD(SP 2010), MCTS(MOSS 2007), MCAD(.Net), MCSD(VS 6) | London, United Kingdom (My Blog)
    Tuesday, August 2, 2011 2:30 PM
  • When you create the lookup column, there is an option to "Add a column to show each of these additional fields." The additional fields will not appear as hyperlinks, so you can use those in the view instead.
    Thursday, May 30, 2013 4:57 PM