List Box Multiple Select does not select a value
Essentials 4.7.0 HTML5 2.8.1
I have a List Box on a Display Form with the selection mode set to Multiple. When I select a value, or multiple values, in the ListBox, the resulting Object is empty. When I set the selection mode to Extended, the same thing. But when I set the selection mode to Single, it returns the selected value.
Is this a known bug? Is there something else I need to do to get multiple selections from the LIsBox?
0
-
Encountered this myself. Definite bug, output is object[] but forms thing that it's just an object and will fuss if you try assigning the output to an array. Just cast after the fact for now. 0 -
I am casting it - to a string. That I then evaluate to see if the string/object is empty so I know whether the user has made a selection or not. I always get the "empty" cast result - System.Object[] - instead of the content of the selection. Not sure what you are sugesting I do instead. What do you mean by "cast after the fact"? 0 -
Cast to object[] first. The return of a string-casted array of objects will just be the type, which you're getting. Same as if you were trying to cast a list of ints... you'll get "system.generic.list<System.int32>" or whatever. Cast to an array of objects and iterate through it to get your strings, or use string.join. 0 -
I see. I'll give that a go. Thanks! 0 -
Any fortune? 0 -
Ok. I've got my DisplayForm output Object cast into an array of objects. If the user makes any selection, I can extract the resulting strings and all is well.
I'm having trouble finding an evaluation for when the user makes no selection. How do I tell if the initial object is empty? If the cast Array has an object that is empty? Every test I come up with gets thrown out because there is "nothing" in my cast array of objects -except the object I cast into it. If I try to evaluate the first object in the array, I get an error that it's not an instance of an object.
What's the secret decoder ring value that will let me know the user has made no selection in the ListBox?0 -
Ah, that's not an issue I've wrangled with yet as my lsitbox is protected by a checkbox that I use to check for the listbox output, and a validator that ensures output in that case. So you are able to cast the object into an empty array? In that case I'd check the length of the array using the .length method (or is it .count?). If that output =0 then you know what (not) to do. 0 -
How about adding a 'required' validation against the listbox? Then the user won't be able to proceed without selecting a value 0 -
Unfortunately, not selecting any option is a valid choice for this ListBox operation. But Zack's worakaround does provide a solution, once you get the hang of it.
Here is the recipe for extracting selected values form a Listox set to Multiple selection mode:- Cast the FormItem ListBox Output variable - objListBoxValue - into an ArrayOfObject variable (Object[ ])
- If the ArrayOfObject.Count() > 0 then
- For Each<Object> in ArrayOfObject
- Assign item.ToString to stringOutputValue
- ELSE
- Assign stringOutPutValue = "System.Object[ ]" (Or whatever you want to indicate an Empty output)
- For Each<Object> in ArrayOfObject
Thanks again to Zack Robison for the answer!0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
9 Kommentare