Last active
February 27, 2021 21:46
-
-
Save melamriD365/02b88ec03b6d8567294f514d7e6f8618 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(typeof(MEA)=="undefined"){MEA={}}; | |
if(typeof(MEA.OptionSet)=="undefined"){MEA.OptionSet={}}; | |
if(typeof(MEA.OptionSet.Utilities)=="undefined"){MEA.OptionSet.Utilities={}}; | |
MEA.OptionSet.Utilities = { | |
//Cascading Utility | |
optionSetBValues : null, | |
Cascade: function (executionContext, optionAName, optionBName, dependecies) { | |
var formContext = executionContext.getFormContext(); | |
var selectedAValue = formContext.getAttribute(optionAName).getValue(); | |
var optionSetBControl = formContext.getControl(optionBName); | |
if (optionSetBValues == null) | |
optionSetBValues = optionSetBControl.getOptions(); | |
if (selectedAValue != null) { | |
optionSetBControl.clearOptions(); | |
var dependeciesB = dependecies.find(d => d[0] == selectedAValue).slice(1); | |
var filtredOptionB = optionSetBValues.filter(v => dependeciesB.includes(v.value)); | |
filtredOptionB.forEach(d => { | |
optionSetBControl.addOption(d); | |
}) | |
} | |
else { | |
optionSetBControl.clearOptions(); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment