1

I am trying to get cascading dropdowns to work on a list, but I seem to be missing a point somewhere. Please help me out.

I have added jQuery and jquery.SPServices to my masterpage.

The dropdown should eventually cascade 3 source lists in a 4th list "Orders":

  1. Categories (Columns: Title)
  2. SubCategories (Columns: Title | MainCategory)
  3. Items (Columns: Title, SubCategory)

SubCategories has a lookup column to the Title column of Categories. Items has a lookup field to SubCategories.

In the NewForm.aspx in my Orders list I have added this code:

<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
    <SharePoint:UIVersionedContent UIVersion="4" runat="server"><ContentTemplate>
        <SharePoint:CssRegistration Name="forms.css" runat="server"/>
            <script type="text/javascript">
                  $(document).ready(function() { 
                        $().SPServices.SPCascadeDropdowns({
                           //Name of list correct
                           relationshipList: "SubCategories",
                           //Name of Column correct
                           relationshipListParentColumn: "MainCategory",
                           relationshipListChildColumn: "Title",
                           childColumn: "SubCategory",
                           debug: true
                        });

                  });
            </script>
        </ContentTemplate>
    </SharePoint:UIVersionedContent>
</asp:Content>

I have two questions regarding this: 1. Why does it not work and how to rectify it? 2. Where can I place this code, so I do not need to repeat it in the editForm.aspx?

/EDIT: Is it possible, that I have this code just in the wrong place for it to work? It is located in the newform.aspx of my Orders list, but references the SubCategories list. I am not sure about this, since the documentation does not cover this point clearly.

  • What does not work about it? do you get errors from the debug or are you getting javascript errors in the console? – Eric Alexander Jul 22 '14 at 15:12
  • No error at all. No debug message - nothing. If I use the list GUID as the relationshipList: variable I am getting a internal Server error, but thats it. I've appended an alert('foo'); aber the SPCascadeDropDown() function call, which works. But the cascading itself does not. – Marco Jul 22 '14 at 15:13
1

Have you tried adding the "parentColumn" option also? This is something I tried a while ago and wrote some comments that may be helpful.

 //State - County Dropdown list
$().SPServices.SPCascadeDropdowns({
relationshipList: "County", //Top List County and States columns
relationshipListParentColumn: "Title", //State column in the Top List
relationshipListChildColumn: "County", // County column in the Top list
parentColumn: "State", //Display name in the web part (From the State list)
childColumn: "County" //Display name in the web part (From the County list)
});

Regarding the placement of the code; if you are going to use the exact same code, I would probably use:

<script type="text/javascript" src="myScript.js"></script>
  • This does not help unfortunatly. – Marco Jul 22 '14 at 13:16
  • Check if the version of jQuery and SPServices you are using are compatible. In some of my projects I had to use SPServices-2013.01 instead of the latest (14.01) – cubanGuy Jul 22 '14 at 18:19
  • Tried it. Unfortunatly this changes nothing in the result. The javascript just does not seem to load. – Marco Jul 23 '14 at 8:30
0

I have found the error. Let me first explain how I found it: I recreated the scenario found at the project wiki, but without bothering about any extra options, like is this field required, whats the max length of this property and so on. After this I added the code from the linked wiki into the newform.aspx. After calling up this form in the browser I recieved some javascript errors in the developers console, which on my Orders list, I didn't. As it turned out, I misspelled a column in my States list. I corrected it and the code worked.

Now, after having a working and a non working example in one SiteCollection, I compared the settings on the lists. As it turned out, the columns for Category, Subcategory & Item on my Orders list were mandatory, where those on my CascadingTest list from the wiki, they were not. After I unchecked "must contain values", the script run.

I'll leave this unanswered for a few days. May be someone comes up with an explanation to this.

0

I had same issue where my parentColumn and childColumn were required fields. Once made them optional then it worked again. Not sure if SPServices has a way to deal with them if required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.