locked
cascading lookupfields/dropdownlists of SharePoint lists

    Question

  • How to implement cascading lookupfields/dropdownlists of SharePoint lists?

    Assume we have two lookup fields:

    1. a list of countries
    2. a list of cities, that belong to countries

    If one chooses a country in the New- and EditForm.aspx page the dropdownlist of the cities should only display cities that belong to the prior selected country! How can this be implemented? Do I need a custom field type for both lists? But how can I access the selected country in my form? Thanks for any hints and tipps!

     

    • Moved by Mike Walsh FIN Monday, May 18, 2009 5:45 PM customization (From:SharePoint - Development and Programming)
    Monday, May 18, 2009 4:20 PM

Answers

  • You need to develop a custom field types for that..Store Countries in one list and store cities in one list. Make lookup field of country title in city list. Refer below links..its shows exactly what you want

    http://datacogs.com/datablogs/archive/2007/08/26/641.aspx
    http://www.biztalkgurus.com/blogs/biztalksyn/archive/2007/08/26/Sharepoint-_1320_-Cascading-Drop-Down-Lists.aspx
    Monday, May 18, 2009 4:35 PM

All replies

  • You need to develop a custom field types for that..Store Countries in one list and store cities in one list. Make lookup field of country title in city list. Refer below links..its shows exactly what you want

    http://datacogs.com/datablogs/archive/2007/08/26/641.aspx
    http://www.biztalkgurus.com/blogs/biztalksyn/archive/2007/08/26/Sharepoint-_1320_-Cascading-Drop-Down-Lists.aspx
    Monday, May 18, 2009 4:35 PM
  • Thanks for the links! It's even the same example (Countries, Cities,...) of the problem ;) Looks like I can use it!

    Monday, May 18, 2009 4:56 PM
  • Moving to customization
    WSS FAQ sites: http://wssv2faq.mindsharp.com and http://wssv3faq.mindsharp.com
    Total list of WSS 3.0 / MOSS 2007 Books (including foreign language) http://wssv3faq.mindsharp.com/Lists/v3%20WSS%20FAQ/V%20Books.aspx
    Monday, May 18, 2009 5:45 PM
  • You can also do this with JavaScript on the page.  If you put hidden Data View Web Parts (DVWPs) on the page with the allowable values and their linkages, you can use JavaScript to manipulate the DOM.  I've done this a few times, and it works quite well.

    M.
    Marc - Sympraxis Consulting LLC - Marc's Blog
    Monday, May 18, 2009 7:00 PM
  • You can also do this with JavaScript on the page.  If you put hidden Data View Web Parts (DVWPs) on the page with the allowable values and their linkages, you can use JavaScript to manipulate the DOM.  I've done this a few times, and it works quite well.

    M.
    Marc - Sympraxis Consulting LLC - Marc's Blog

    Marc,

    I've been searching everywhere for the solution you propose here, but I can't find anything here or online.  I really appreciate guidance on how to implement the DVWP solution for cascading lists.

    Thanks,

    Lee
    Monday, July 13, 2009 8:44 PM
  • Lee:

    I've just added a post to my blog that shows how I did this with JavaScript in one instance:
    http://mdasblog.wordpress.com/2009/07/14/cascading-columns-in-a-sharepoint-form/

    Let me know if I can help with any questions.

    M.
    Marc D Anderson - Sympraxis Consulting LLC - Marc D Anderson's Blog
    Tuesday, July 14, 2009 1:28 PM
  • One more possible solution http://www.sharepointdrive.com/blog/Lists/Posts/Post.aspx?ID=8
    Wednesday, September 30, 2009 1:14 PM
  • Since I posted above, we've made the jQuery Library for SharePoint Web Services available on Codeplex.  With it, setting up cascading dropdowns is a snap.  For your example above, it would look something like this:

    <script language="javascript" type="text/javascript" src="../../jQuery%20Libraries/jquery-1.3.2.js"></script>
    <script language="javascript" type="text/javascript" src="../../jQuery%20Libraries/jquery.SPServices-0.3.1.min.js"></script>
    <script language="javascript" type="text/javascript">
      $(document).ready(function() {
        $().SPServices.SPCascadeDropdowns({
          relationshipList: "Cities",
          relationshipListParentColumn: "Country",
          relationshipListChildColumn: "Title",
          parentColumn: "Country",
          childColumn: "City"
        });
      });
    </script>

    M.
    Marc D Anderson - Sympraxis Consulting LLC - Marc D Anderson's Blog - @sympmarc
    Wednesday, September 30, 2009 1:20 PM