Hi,
I have a UI with CheckBoxListOptions. I want to gather the results so I can see which checkboxes the user selected. Eventually, the list of checkboxes might grow to be 10 or 20+. At the moment I can only get if an individual checkbox has been selected by requesting the DestVar specifically.
Can anyone help me return or generate a List, or something similar where I can easily see all the checkboxes that were selected? I need to work around UIResults not containing a public instance or extension definition for GetEnumerator.
public static UIResults BuildMainUI(IEngine engine, IActionableElement element)
{
UIBuilder mainUI = new UIBuilder();
mainUI.Title = "Arqiva Utility for xx Management";
mainUI.AppendLine("Choose a feature...");
mainUI.AppendLine("Uploading a default configuration");
mainUI.AppendLine("--------------------------------------------");
UIBlockDefinition checkBoxes = new UIBlockDefinition()
{
Type = UIBlockType.CheckBoxList,
Height = 100,
Width = 400,
};
checkBoxes.AddCheckBoxListOption("1", "Upload a Live Encoder default configuration");
checkBoxes.AddCheckBoxListOption("2", "Upload a Live Encoder, Multiplexer default configuration");
checkBoxes.AddCheckBoxListOption("3", "Upload a Live Encoder, Reliable Transport default Configuration");
checkBoxes.DestVar = "destVar";
mainUI.RequireResponse = true;
mainUI.AppendBlock(checkBoxes);
mainUI.AppendLine("--------------------------------------------");
mainUI.AppendLine("Other features...");
UIResults uir = engine.ShowUI(mainUI);
engine.GenerateInformation(uir.GetChecked(checkBoxes.DestVar, "1").ToString());
foreach (var checkedBox in uir)
{
}
if(uir.GetChecked(checkBoxes.DestVar, "1"))
return uir;
}
Hi Ross,
I believe the way you found looping is the only option since I am not aware of an alternative.
You could consider creating a data structure that would have your entire list of options.
Then have a couple of extension methods, one for calling AddCheckBoxListOption for each, and then another that would use the same original dataset and iterate to call GetChecked and return Key-Value pairs with the corresponding boolean flag.
Something like GetCheckedExtensions.cs (github.com)
Thanks for this, I’ve implemented your suggestions as it’s more manageable and scalable. All working perfectly, much appreciated!
FYI – I’ve found a way by looping results.GetChecked(“destVar”, counter)