Use Cascade with Lookup column as first drop-down

Forums Cascading dropdowns Use Cascade with Lookup column as first drop-down

Tagged: ,

Viewing 3 reply threads
  • Author
    Posts
    • #26561
      Brett
      Participant

      Hi Alexander,

      I have looked everywhere but cannot find an answer.
      Is there a method of using a SharePoint lookup column as the first drop-down to then cascade the value to a 2nd text column?
      Thanks,

      Brett

    • #26567
      Alexander Bautz
      Keymaster

      Hi,
      Unfortunately this is not possible. You can however make it work with some custom js and the use of SPJS-Lookup instead. See this example: https://spjsblog.com/forums/topic/combing-spjs-lookup-with-cascading-dropdowns/#post-9408

      If you look at this snippet:

      // Add change event
      $("#Task_x0020_Force_spjs_lookup").change(function(){
      	buildNextDropdown($(this).find("option:selected").text());
      });

      You can change it like this to make it work with a lookup column and use it as your first “cascading dropdown”:

      // Add change event
      $("#dffs_LookupColumnFIN select").change(function(){
      	buildNextDropdown($(this).find("option:selected").text());
      });

      Replace LookupColumnFIN with your lookup column name.

      Alexander

    • #26571
      Brett
      Participant

      HI Alexander,

      Thanks, this worked with rendering the text field as a drop-down with the list of options.
      But the end result is to be like a cascading drop-down which only returns a single value.
      I tried the filterObj setting to return a single value but I can’t figure out how to return a value based on the lookup ID column.

      Does it make a difference if the column values returned is another Lookup column?

      I tihnk it’s easier to replace all lookup columns with Single-line text fields and configure cascading drop-downs in DFFS?
      Thanks for your help anyway 🙂

    • #26573
      Alexander Bautz
      Keymaster

      I’m not 100% sure I understand, but when you use a set of cascading dropdowns the value in each of the fields will be saved and not only the last dropdown – each level must be single line of text field in your form.

      Using the method described above you can nest multiple spjs-lookup’s by attaching a change function and have this call the function to build the next level dropdown using the previous dropdown value as filter.

      If you need the ID of the lookup dropdown item you can change the function from this:

      buildNextDropdown($(this).find("option:selected").text());

      to this

      buildNextDropdown($(this).find("option:selected").val());

      Alexander

Viewing 3 reply threads
  • You must be logged in to reply to this topic.