Multi Selection - SL-List

Jenie888

Member
Is there a way to manually turn multiple selection on or off in a selection list? I would like to use the same selection list for two instances of data, but there is a slight issue. For one instance it must be multi selectable and for the other the user must only be able to select one item at a time.

I couldn't fins an attribute to manually turn it off and on, I wondered if anyone knew of a way to accomplish this.

THanks,
Jenie
 

M-HT

Member
Unfortunatelly this isn't possible.
The attribute exists (selection-list:multiple), but it's read-only (setable only before realization).
I think you will just have to do it with two selection-lists.
 
Hi Jenny,

Roman is right, but you can code around it. If you set the 'multiple' attribute of the selection-list, then at run-time you can use a logical variable to indicate the only single selections are allowed.

For example, if you have a logical variable called 'SingleOnly', then the following trigger will not allow more than one item to be selected when 'SingleOnly' is TRUE.

ON 'VALUE-CHANGED' OF SELECT-1
DO:
IF SingleOnly AND SELF:SCREEN-VALUE <> ? THEN
ASSIGN SELF:pRIVATE-DATA = ENTRY(NUM-ENTRIES
(SELF:SCREEN-VALUE),SELF:SCREEN-VALUE)
SELF:SCREEN-VALUE = ?
SELF:SCREEN-VALUE = SELF:pRIVATE-DATA.
END.

The screen-value of the selection list contains a comma-separated list of all selected items. So the trigger finds the last selected item and stores it in the private-data area. It then clears all selections by setting the screen-value to ?, and then reselects the single item from the value stored in the private-data area.
 
Top