A Data Transform can be used in Pega 7.1.9 to sort list structures such as a Page List. In this example, a Data Transform is used to sort Pega 7 dropdown options that are backed by a List-type Data Page. In addition, another Data Transform is shown that sorts the Page List based on two properties.
- Description of Data Type and Data Page for Storing Cell Phone Models
- Using an Activity, Section and HTML Rule to Display a Dropdown of Phones
- Using a Data Transform to Sort the Page List
- Group Pega 7 Dropdown Options by Property
- Configure a Pega 7 Auto-Complete Control Backed by Data Table
- Example of Cascading Drop Downs in Pega 7
1 Description of Data Type and Data Page for Storing Cell Phone Models
- Here, a Data Type named
PGX-MyStore-Data-Phonewas created using the Data Explorer.
- The Definition tab of the Data Type shows its properties:
- The Records tab shows the
13instances that have been created for this Data Type.
- The Sources tab shows the 2 Data Pages that have been created automatically.
- The data page
D_PhoneListis of type List and can be used to retrieve all instances of the
- Use Actions > Run to run the data page and view its XML representation. There will be a node called
pxResultsthat contains the list of phones.
2 Using an Activity, Section and HTML rule to Display a Dropdown of Phones
- A form was created to show a dropdown that allows to select a phone based on the
- Clicking on the dropdown shows the options provided by the Data Page. Note that the order of the items is the same as shown on Data Type > Phone > Records, i.e. the list is sorted ascending by the
- The following rules were used to create the HTML page with the phone dropdown control:
ShowPhoneOrderSectionSection rule containing the dropdown control is shown below:
- The configuration of the Dropdown rule is shown below, note the List source section, which refers to the Data Page:
MyPhoneStoreHTML rule uses the <pega:include> tag to include the section rule by name.
<pega:include name='PhoneOrderForm' type='Rule-HTML-Section'></pega:include>
ShowPhoneOrderSectionActivity rule contains one step that uses the Show-HTML method to render and display the HTML rule.
- When running the Activity using Actions > Run, it will display the HTML page shown at the beginning of this section.
3 Using a Data Transform to Sort the Page List
- A new Data Transform called
SortByPhoneNameASCwith an applies-to class of
PGX-MyStore-Data-Phonewas created. On the Pages & Classes tab, the following entries have to be added:
D_PhoneListwith class name
D_PhoneList.pxResultswith class name
- On the Definition tab, the first and only step uses the Sort method.
- The gear icon is used to configure the
Sortmethod. Clicking on it opens a new layer.
- Here, the Sort method is configured to sort the list of phones by the
PGX-MyStore-Data-Phonein ascending order.
ShowPhoneOrderSectionActivity was modified and a step was added before displaying the HTML page.
- The first step in the modified Activity uses the Apply-DataTransform method to use the
SortByPhoneNameASCData Transform for sorting the Data Page.
- The step page is referring to a page that is defined on Pages & Classes. This entry is needed because the Data Transform’s applies-to class is different than that of the Activity, which is
- When the Activity is run again, the options in the phone dropdown control are now sorted by
Namein ascending order.
- Another Data Transform was created to sort the phone list by
Memory(ASC) first and then by
ScreenSize(DESC). The configuration is shown below.
- If two or more phones have the same amount of memory, they will be sorted by screen size in descending order, i.e. the one with the largest screen size will be on top in that subset of the list.
- The Data Transform can be run by using Actions > Run.
- In the Run Data Transform dialog, click on the Trace button first and the on the Run button.
- In the Tracer, where the event type is
Action Endclick on the cell that lists the Data Page, here
D_PhoneList, to view the Data Page after it has been sorted by the Data Transform.
- The dialog lists the items of
- The phones are sorted in ascending order by memory first. In addition, the phones with 16GB of memory are sorted in descending order by screen size.