How to create Combobox input (Editable Dropdown)

Document created by cdtj Champion on Jan 11, 2017Last modified by cdtj Champion on Jan 11, 2017
Version 2Show Document
  • View in full screen mode

This thing is needed when your customers wants to select value from existing list and to have possibility to create a new ones but they are too lazy to use Lookups

 

Demonstration

 

Code

 

My attribute called spec located in z_wf_wl factory. Notepad's Replace all function should be enough to refactor this code.

 

form side:

function switchComboBox(obj) {
     if (!jq("#spec_attr").length)
          jq("[pdmqa='spec_fake']").parent().append(
               jq(document.createElement('input'))
               .attr({id : "spec_attr", name : "SET.spec"})
               .hide()
          );
     if (jq(obj).val() == "<NEW_VALUE>")
          jq("#spec_attr").show().val("");
     else
          jq("#spec_attr").hide().val(jq(obj).val());
}
detailSetEventHandler("onchange='switchComboBox(this);'");
detailDropdown("Specialization", "spec_fake", "pri", 1, 40,
     false, "", "$args.spec",
     "no", "spec", "$args.spec",
     "","","no","","",
     "$args.spec",
     <PDM_LIST prefix=list where="spec is not NULL" factory=z_wf_wl domset="spec_types">
          "$list.spec", "$list.spec",
     </PDM_LIST>
     "New Type:", "<NEW_VALUE>"
);

 

spel side:

// Filename: wf_wl.maj
// This one used to list all unique values used for "spec" attribute
OBJECT z_wf_wl {
     FACTORY {
          DOMSET spec_types "spec" STATIC {
               DISTINCT;
          };
     };
};
1 person found this helpful

Attachments

    Outcomes