Table of Contents

Article

How to allow users to select multiple items from a SelectList control

Summary

A developer asks: Can I allow an application user to select multiple elements from a SelectList control? The possible choices are in a Value List property.

I was able to build the HTML code for this in an HTML Property rule, but am not sure how to get the users's selections.



Suggested Approach

Such multiple selections are not supported by any standard HTML property rule. As a best practice, you can present a list of labeled check boxes.  

Update: In V5.4+, a separate HTML property rule MultiSelectList is available, so the approach described here is not necessary. For an example use of the MulitSelectList rule, review the standard section rule PegaAccel-Task-CircumstanceSearch. FindByCircumstance_Circumstances.

You need a Page List that contains a property — for example the standard property @baseclass.pySelected — that is presented as a check box, and properties that name the things you want to list. 

Populate the Page List with all the entries from which you wish to select. 

Build an HTML display that, through a ForEach directive on the elements of the Page List, displays a check box and the choice element.  If the list is long, you may want to employ a scrollable <DIV > element.

Basically, after the user enters his choices, your Page List needs to contain, for each element, a name and a value indicating whether that element is selected.

Published April 7, 2005 — Updated November 15, 2015


50% found this useful

Have a question? Get answers now.

Visit the Pega Support Community to ask questions, engage in discussions, and help others.