Creating a ‘bill-of-materials’ type structure

Home Forums vLooup for SharePoint Creating a ‘bill-of-materials’ type structure

Viewing 1 reply thread
  • Author
    Posts
    • #31023
      DougMcCourt
      Participant

        Hi Alexander –
        Am looking to implement a semi bill of materials type structure for a dependency type construct

        Parent list: “Deliverables” (imagine a list of business deliverable for a team”
        Child List: “Dependencies” this list defines the predecessor / successor relationship between two deliverables. Using Vlookup to created the parent child relationship between Deliverables –> Dependencies. “dependencies” has a standard SP Lookup for the related (subordinate) Deliverable called “Related Deliverable”. All works perfectly.

        Use Case: is I would like to filter the list of Deliverables presented in the “Related Deliverables” lookup based on another lookup (or text) field in the child/Dependency listitem that is in context (CurrentItem} in EditForm or NewForm

        Deliverables list has approx 600 items in it, which is a bother to scroll through
        The field I want to use to filter should cut it down to a max of 20 or so.
        The field I want to use to filter is NOT a multi select – and using the same underlying SP list as the source for the lookup in both the Deliverables list, and the Dependency list

        Sorry if this is too much of a ‘how too’ – and thanks for all of your support over the years!

      • #31031
        Alexander Bautz
        Keymaster

          I created this simple filter for a multilookup field – maybe you can use it as a starting point and see what you can do.

          Add this to your Custom JS:

          function filterMultiLookup(elm, fin) {
              var s = jQuery(elm).text().toLowerCase();
              if (s === "") {
                  jQuery(elm).addClass("customFilterEmpty");
              } else {
                  jQuery(elm).removeClass("customFilterEmpty");
              }
          }
          
          function applyMultiLookupFilter(fin) {
              var s = jQuery("#filter_" + fin).text().toLowerCase();
              jQuery("#dffs_" + fin + " select:first option").each(function() {
                  if (jQuery(this).text().toLowerCase().match(s) || jQuery(this).val() === "0") {
                      if (jQuery(this).parent().is("span")) {
                          jQuery(this).unwrap().show();
                      }
                  } else {
                      if (!jQuery(this).parent().is("span")) {
                          jQuery(this).prop("selected", false).wrap("<span>").hide();
                      }
                  }
              });
          }
          
          function addFilterToMultilookup(fin) {
              jQuery("#dffs_" + fin).find("td.ms-formbody").prepend("<div style='margin-bottom:4px;'><div id='filter_" + fin + "' placeholder='Type here to filter the list...' class='customFilter customFilterEmpty' contenteditable='true' onkeydown='if(event.keyCode===13){applyMultiLookupFilter(\"" + fin + "\");return false;}' onkeyup='filterMultiLookup(this,\"" + fin + "\")'></div><input type='button' onclick='applyMultiLookupFilter(\"" + fin + "\")' value='Filtrer' /></div>");
          }
          
          addFilterToMultilookup("MultiLookupPartNumber");

          Just change the fieldinternalname in the addFilterToMultilookup function call in the last line.

          Also add this to your Custom CSS:

          /* Filter over multilookup */
          .customFilter{
              width:300px;
              display:inline-block;
              margin-bottom:2px;
              padding:2px 4px;
              border:1px silver solid;
              cursor:text;
          }
          .customFilterEmpty::before {
              content: attr(placeholder);
              color: #c5c5c5;
          }

          Alexander

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