Cascading Filter Requirement

Feb 6, 2014 at 4:56 PM
Hi Guys,

I have a requirement here. Can anyone suggest me an alternate to implement this behavior using SPServices Framework.

Lookup : Country
Lookup : Regions (filter based on Country)
Lookup : Cities (filter based on Country).

Here Region and City are not related in anyways other than Country

Country List : ID, Title
Region List : ID , Title, Country
City List : ID, Title, Country

Thanks a lot in advance !!!!
Nutan
Coordinator
Feb 6, 2014 at 5:47 PM
Nutan:

Just set up the two cascades with SPCascadeDropdowns using the settings you've indicated. It ought to work, as long as Region.Country and City.Country are both lookups to the Title column in Countries.

M.
Feb 7, 2014 at 1:24 PM
Edited Feb 7, 2014 at 1:37 PM
Hi Marc,

Thanks for the quick response. I am glad.

I tried the same scenario again and found that it breaks when all the three look-ups are mandatory.

It worked fine when i initially created every list and column. But as soon i made them compulsory, the City Look-up failed to filter the data based on country.

Here is what i did :
Country List : ID, Title
Region List : ID , Title, Country
City List : ID, Title, Country
Sample List : ID, Title, Country Lookup (mandatory), Region Lookup (mandatory), City Lookup (mandatory)

It starts working if I keep City as optional field and Country, Region mandatory.

In my case, its compulsory to select all three values. Can you check this and verify if it works or its a bug to be fixed..

Awaiting your response.

Thanks,
Nutan
Coordinator
Feb 7, 2014 at 2:30 PM
Sounds like you are probably on Office365? There was a recent update that changed the markup for required field in forms (among other things).

Can you please let me know what version of SharePoint you are running, whether it's Office365, etc.?

The latest alpha of 2014.01 should fix this issue, so please give it a try and let me know how it goes.

M.
Feb 7, 2014 at 2:59 PM
Yup, its O365 ..I will check out the latest alpha :).

I must say you have done a wonderful job here. This framework has been a great help for developers.

Thanks a lot.
Nutan
Coordinator
Feb 7, 2014 at 4:34 PM
Edited Feb 7, 2014 at 4:35 PM
Glad you like SPServices!

From the email you sent. (Let's keep the discussion here, ok?):

Based on your suggestion i used the latest alpha of 2014.01 but Its not coming along..same behavior..posting the script as below..let me know if anything is missed..
<script type='text/javascript' src='/sites/Test/Style%20Library/jquery-1.10.1.js'></script>
<script type='text/javascript' src='/sites/Test/Style%20Library/jquery-1.10.1.min.js'></script>
<script type='text/javascript' src='/sites/Test/Style%20Library/jquery.SPServices-2014.01ALPHA2.js'></script>
<script type='text/javascript' >
   $(document).ready(function() {    
                
        $().SPServices.SPCascadeDropdowns({
            relationshipList: "Regions",
            relationshipListParentColumn: "Country",
            relationshipListChildColumn: "Title",
            parentColumn: "Country Required Field",
            childColumn: "Regions Required Field",
            debug:true
          });
          
        $().SPServices.SPCascadeDropdowns({
            relationshipList: "City",
            relationshipListParentColumn: "Country",
            relationshipListChildColumn: "Title",
            parentColumn: "Country Required Field",
            childColumn: "City Required Field",
            debug:true
          });
    });     
</script>
You're loading jQuery twice (both the minified and non-minified version,) which may be causing problems.

You should remove the " Required Field" text from the column names. That's not the column name, but what is now the title of the select elements. The column names should just be
            parentColumn: "Country",
            childColumn: "Regions",
etc.

M.
Feb 10, 2014 at 6:04 AM
Voila, it worked by removing the Required Field text. Actually as per the documentation , I saw its the display name of the field.
But with the earlier versions of script, I see that the script access the select object by title and in O365, for a compulsory field, SharePoint appends a Required Field Text with the Title. So I was getting "Column Not Found" Error if I don't put that.

Seems now it supports O365, we don't need to append it. Working pretty good :)


Thanks & Regards,
Nutan
Coordinator
Feb 10, 2014 at 2:57 PM
Great to hear. Thanks for the confirmation that it's working for you.

M.