bound-repeat-sort
A HTML content command that makes it host element a control for sorting the items of a bound-repeat on the same Screen. The control presents a defined set of sorting options and so the host element is expected to be a <select>
element.
The primary attribute expression of bound-repeat-sort
is expected to match the bound-repeat-name
value of a bound-repeat
on the same Screen, defining the repeat and its Collection that will be sorted by interacting with the host element.
The different sorting options are defined by providing a Collection of Maps with specific keys through the bound-repeat-sort-options
secondary attribute. Each Map has to contain three entries:
label - Defines the label that will be displayed for this sorting option in the selection. The value is expected to be a String.
sortKey - Defines the key by which the items in the Collection are sorted, assuming each item is a Map or a Data item. If, for example, each item has a name-specifying entry with the key "name", having "name" as the value for this entry causes the items to be sorted by their names. The value is expected to be a
String
.ascending - Defines if the sorting order is ascending or descending. The value is expected to be a Boolean, with
true
producing an ascending order andfalse
producing a descending order.
Secondary attributes
bound-repeat-sort-options | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | Collection | Yes |
Defines the set of sorting options. The resolved value is expected to be a Collection containing certain kinds of Maps, as specified in the command documentation. |
Examples
Using bound-repeat-sort
requires preparation in the form of creating a Collection of the possible sorting options. Assuming we have a bound-repeat
with the name "boxes" with a Collection of Map items behind it, with each item having an entry with the key "Size", there could be a set of sorting options as follows created in the logic:
<setMap var="sort1"><addMapEntry key="label" value="Smallest box first"><addMapEntry key="sortKey" value="Size"><addMapEntry key="ascending" value="${true}"><setMap var="sort2"><addMapEntry key="label" value="Biggest box first"><addMapEntry key="sortKey" value="Size"><addMapEntry key="ascending" value="${false}"><setCollection var="sortOptions"><addItem value="${sort1}"><addItem value="${sort2}">
This Collection can then be used to configure bound-repeat-sort
in the Screen HTML:
<select bound-repeat-sort="boxes" bound-repeat-sort-options="sortOptions">