Skip to main content
Version: v11.6.2

Creating an Employee List grouped by Birth Month and City

Scenario: To display list grouped by multiple fields like City and State they reside in

We will see how List items can be grouped by multiple fields. We will

  1. List of Employees grouped by Birth Month and City of Employees.
  2. A custom JavaScript function is used to manipulate the dataset returned to achieve multi-field grouping.
  3. Static Variable is used to get the month names in Order.

We have used the following code snippets:

  • JSON file for list of months static variable: { "0": "Jan", "1": "Feb", "2": "Mar", "3": "Apr", "4": "May", "5": "Jun", "6": "Jul", "7": "Aug", "8": "Sep", "9": "Oct", "10": "Nov", "11": "Dec" }
  • JavaScript for the OnBeforeDatasetReady event: Page.EmployeeVaronBeforeDatasetReady = function(variable, data) { var dataByMonth = .groupBy(data, function(datum) { //getting the employees grouped by their birth month return new Date(datum.birthdate).getMonth(); }); data = []; .each(dataByMonth, function(employees, month) { //for each of the month, getting the array of employees born on that month. data.push({ 'birth_month': month, 'employees': employees }); }); return data; };

List Use Cases