问题
My report has a parameter which uses a base enum. The enum has 4 different options to choose when running the report. How do I insert an option which uses all 4 at once?
For example, I have an enum named Phone and it has 4 types: 1 = None, 2 = Home, 3 = Mobile, 4 = Work. In a drop down, how do I add option 5 = None+Home+Mobile+Work?
Thank you!
回答1:
Add anoher enum with value All (see NoYes and NoYesAll enums as example)
回答2:
Some ways to solve your problem:
You can alter your Enum and add a new EnumValue with something like "All" (like AxCoder answer).
If you don't want (or you can't) modify this Enum you can copy it and create a new Enum with the New value. It will be your responsability to maintain both syncronized with future changes.
And you can leave the Enum without changes, and add another parameter to the report for you to know that the Enum value needs to be ignored by the Query (you have to code that beaviour, obviously)
Hope this helps.
回答3:
You can add to the combo box on the form. If you use the enum on the form as a ComboBox, make sure the AutoDeclare property is Yes. Overwrite the Run() method of the form and add to the combo box after super.
Example:
public void run()
{
super();
YourComboBox.add("All");
}
On the modified method of the combo box, add the check for the word “All” by adding the code below before ret = super():
if (YourComboBox.getEditText() == "All")
{
info("do your stuff"); //Add your code for the all selection here
}
来源:https://stackoverflow.com/questions/2480536/enum-as-a-parameter-in-dynamics-ax