Limiting the number of levels that can be selected.

Forums Cascading dropdowns Limiting the number of levels that can be selected.

Viewing 1 reply thread
  • Author
    Posts
    • #32596
      Carl E Tippins
      Participant

      We have a request to limit the number of items that can be selected in a cascade must-select to 2. Is this possible?
      Current code (Ignore any errors, had to manually type it):

      function AlLoc(){
      var resType = getFieldValue(“Resource_x0020_Type”);

      if (resType == “CLP Contractor” || resType == “Contractor” || resType == “FTE B4 – B9” || resType == “SP Onshore”){

      var mgr4 = getFieldValue(“DFFSMgr4LName”);
      var Loc2 = getFieldValue(“LocCat2”);

      spjs.casc.init({
      ‘manualMode’:true,
      ‘lookupList’:’Lookup-Location’,
      ‘lookupListBaseUrl’:'{currentSite}’.
      ‘lookupListFields’:[“LocCat2″,”ST_x002d_City_x002d_Address”],
      ‘thisListFields’:[“LocCat2″,”AlternateLocations:multi”],
      ‘droupDownDefaultvalue’:”,
      ‘filter’:'{“filterField”:”ValidForTE”,”filterValue”:”‘ + mgr4 + ‘”,”operator”:”substringof”}’,
      ‘hideEmptyDropdowns’:false,
      ‘autoselectSingleOption’:true,
      ‘clearInvalidSelection’:true,
      ‘sideBySide’:true,
      ‘debug’:false,
      });
      }
      }

    • #32598
      Alexander Bautz
      Keymaster

      You can add this to your Custom JS:

      setInterval(function () {
          var len = jQuery("#AlternateLocations_casc").find("option").length;
          if (len > 2) {
              jQuery("#AlternateLocations_casc").find("option:last").prop("selected", true).trigger("dblclick");
              spjs.dffs.alert({
                  "title": "To many!",
                  "msg": "You can only select 2 items.",
                  "ok": function () {
                      // Close dialog
                  }
              });
          }
      }, 1000);

      Alexander

      • #32602
        Carl E Tippins
        Participant

        Thanks Alexander, it worked like a charm!

      • #32606
        Alexander Bautz
        Keymaster

        Great! – thanks for the feedback.

        Alexander

Viewing 1 reply thread
  • You must be logged in to reply to this topic.