locked
Problem with lookup field in list RRS feed

  • Question

  • I have a custom list which contains a column that is a lookup to another list.  The column is called tasks:


     
    As you can see it is a lookup column without link.  However if you look at the image below (AllItems.aspx View) you can see that the column is in fact a link back to the original list the lookup is referring to. 



    This is a problem because it gives a user the opportunity to delete the value from the original list (if they have permission).



    What I ultimately would like is to have the lookup value just be text, not a link.

    Does anyone know how I can achieve this or is this a bug.

    Sincerely,
    Tim
    Wednesday, August 12, 2009 1:31 AM

Answers

  • I agree with GuYuming, if you still you want to set the 'Tasks' items to non-hyperlink you can do this by using Sharepoint Designer
    • Open the AllItems.aspx page in SPD
    • Select ListViewWebpart, right click and select 'Convert to XSLT Data View'
    • Select the 'Tasks' column item, let's suppose '3rd Party Orders' select it and look into code area you can see the selected code area part belongs to the tasks items like below (not exactly)
    <xsl:otherwise><A HREF="{ddwrt:URLLookup('{1a38c8d8-f2ce-420b-b9c3-f44b70698bbe}', 'Tasks', string(@ID))}"> <xsl:value-of select="@Tasks" /></A> </xsl:otherwise>

    Remove the anchor tag (above bold once) from either side of xsl value tag
    • Marked as answer by SPA-TMF Wednesday, August 12, 2009 12:11 PM
    Wednesday, August 12, 2009 11:25 AM

All replies

  • This should be as simple as, going into settings and list settings to get back to the original view of your site columns for this list as you have shown in the first screenshot, clicking back on tasks, and changing the "in this column" drop-down list from including "(links to items)" to the option that is not linked to item.  This should solve your problem, you must have accidentally selected this option when you first set up the column.

    However, if this is not the problem, I have seen in the past, although it is very rare, where you have "title" (this label used obviously can be changed) has actually been change in content types,  and what you have listed as a column entitled "tasks" is actually the true title.  This is very difficult to do, although I have seen it screw some people up, and only happens if you've been playing around with content types without knowing exactly what you're doing. Some may even disagree that this can be done, but believe me it can be. If this is the case, rather than the first scenario, then it would show up as one of the options under your views, and where normally the title would have an option as showing as a link, it would actually show that "tasks" has an option to show as a link, because that would be the true title.  This scenario is highly unlikely, and it may be impossible as it regards to a lookup column, but I just thought I would share it just in case.

    Please let me know if the first scenario helps you, or if I've completely missed your question :).
    Brian K. Woytovich ( Treebreeze ) The Proficients Project Inc.
    Wednesday, August 12, 2009 5:45 AM
  • I really don’t think formatting a lookup column as a hyperlink is inappropriate.  It should be by design. Otherwise, it would be difficult for user to navigate to details of the lookup value. You should set the permissions in lookup list to prevent the item from being deleted.

     

    If you still insist on your unique requirement, you may a create a custom field type which inherits the Lookup field type.

    Wednesday, August 12, 2009 8:13 AM
  • I agree with GuYuming, if you still you want to set the 'Tasks' items to non-hyperlink you can do this by using Sharepoint Designer
    • Open the AllItems.aspx page in SPD
    • Select ListViewWebpart, right click and select 'Convert to XSLT Data View'
    • Select the 'Tasks' column item, let's suppose '3rd Party Orders' select it and look into code area you can see the selected code area part belongs to the tasks items like below (not exactly)
    <xsl:otherwise><A HREF="{ddwrt:URLLookup('{1a38c8d8-f2ce-420b-b9c3-f44b70698bbe}', 'Tasks', string(@ID))}"> <xsl:value-of select="@Tasks" /></A> </xsl:otherwise>

    Remove the anchor tag (above bold once) from either side of xsl value tag
    • Marked as answer by SPA-TMF Wednesday, August 12, 2009 12:11 PM
    Wednesday, August 12, 2009 11:25 AM
  • Thank you both for your help!!!

    As you (SP RAJ) indicated I did not originally setup the column as a link-to-items field.  Nor is the list tied to a content type.  However, the template was the Budgeting and Tracking Multiple Projects template and it did have tasks as a site column for a content type and perhaps that is causing the issue or conflict.

    I am going to use your later suggestion and edit the xsl to remove the anchor tag.

    I will let you know how it goes.

    Sincerely,
    Tim
    Wednesday, August 12, 2009 12:05 PM
  • Awesome!  It worked and all is well. 

    Thank you again!

    Sincerely,
    Tim
    Wednesday, August 12, 2009 12:11 PM
  • So what I just encountered is that although this works for a a form page or a view accessed from the list itself, it fails when attempting to use the custom view in a web part.

    I added the list web part to my main page and then attempted to change the view to the custom view I enhanced by removing the anchor tags around the lookup field.

    This is the error I get when trynig to use this view:

    Wondering if I should hide the original form (visible="false") and then add a new dataview form and modify the form there? Any ideas? Thank you. Sincerely, Tim
    Wednesday, August 12, 2009 4:10 PM
  • When you covert any view to XSLT Data view, the view will not  be displayed properly when you try to select the particular view from list webpart properties.

    If you want to display the list webpart on the main page then you can create one more view through list settings page, while creating the second view please uncheck the lookup column if not the lookup column still renders as hyperlink and points to it's own list, then after you can use the second view newly created one on the main page
    Friday, August 14, 2009 11:52 AM
  • Thanks for your Reply Raj,

    It worked for me.

    Thanks
    Sivannarayana
    • Proposed as answer by shiva.g Wednesday, September 9, 2009 1:04 PM
    • Unproposed as answer by Lambert Qin [秦磊] Monday, January 4, 2010 8:34 AM
    Wednesday, September 9, 2009 1:04 PM