Hi,
I want to pass a table of Elements, or elementNames into a UI drop down menu but I'm getting errors. I'm trying many different things (I've only shown a couple below that best describe what I'm trying to do) but none output what I want. I've tried using a foreach element in element[], list.Add(); but I also can't get lists to populate the drop down either. I've kept my code to Element tables below to keep it simple. Hopefully there's enough there to start.
Any help much appreciated!
ElementFilter filter = new ElementFilter()
{
View = "myFilter"
};
string myString = ("ABC");
Element[] elements = new Element[10];
elements = engine.FindElements(myFilter);
Element abcElement = Array.Find(elements, x => x.ElementName.Contains(myString));//working
myUIB.AppendDropDown("try1", $"1|{Array.FindAll(elements, x => x.ElementName.Contains(myString))}");
myUIB.AppendDropDown("try2", $"1|{Convert.ToString(elements.Contains(myString))}");
myUIB.AppendDropDown("try3", $"1|{Convert.ToString(list.Contains(myString))}");
I'm wondering if the 'value|display value' needs to be generated with a foreach loop or something similar. I have tried but I ended up with a drop down for each element within the table.
My various attempts give the following errors..
Thanks,
Ross
Hi Ross,
With the AppendDropDown method, you are adding additional dropdown widgets to your view.
Instead of using that method, I recommend you create and add the dropdown like this:
var dropdown = new UIBlockDefinition
{
Type = UIBlockType.DropDown,
Row = 0,
Column = 0,
WantsOnChange = true,
DestVar = "selectedElement",
};foreach (var element in elements)
{
dropdown.AddDropDownOption(element.Name);
}uiBuilder.AppendBlock(dropdown);
If you own a DIS license, I recommend you consider using the IAS Toolkit library which makes it easier to create interactive automation scripts.
More info about the library or on interactive automation scripts in general can be found in these video courses: https://community.dataminer.services/courses/dataminer-automation/
The Advanced level section will be the most useful for what you are making.
Thanks, this helped me a lot. I can confirm everything working as expected.