(Un)check all items in a K2 SmartForms Choice Control

Markus Kolbeck
Markus' Blog
Published in
3 min readNov 18, 2015

If you have a list with items in a K2 SmartForms Choice Control and you want to (un-)select all of them at once rather that checking each one of them, here’s one solution.

BTW: this also works for the K2 SmartForms “Check Box List” Control.

The Result

You can use a K2 SmartForm Control (button, checkbox) to select all or un-select all

K2 Designer - View

K2 Designer — View

Here are the steps:

Create the View

K2 Designer - Canvas

The view will contain the control to display the list items, in my case the Choice Control.

It will retrieve it’s data from a SmartObject. It is very important to configure the Delimeter with the same character that we use later in the rule.

K2 Designer - Choice Control - Properties

In addition the view will need a Data Label Control (dlblAllValues)that stores the values for all items in the list view.
(I did not hide that control so that you can view the values)

The last control that is needed is a trigger, e.g. a Check Box Control. When checked, all list items are selected.

Create the Rules

When the View initializes, we want to populate the Choice Control based on SmartObject Data.

Also, we transfer all IDs from the Choice Control to the Data Label Control — remember to use the same Delimeter!

K2 Designer - Rules - Initialize

Another rule is needed for (un-)selecting the items: when the Check Box Control changes values.

If the Check Box Control is checked, i.e. true, transfer all IDs from the Data Label Control (dlblAllValues) to the Choice Control.

Otherwise transfer empty values (within the Mapping Destinations just check the Choice but do not add anything to the input box).

K2 Designer - Rules - Change

Other than someone might expect, we do not assign a true or false value to the list items for (un-)selecting them:
It will be the values of the Identifier we chose within the SmartObject method (in my case the ID) that need to be assigned to the Choice Control.

--

--