The group by filter is useful when you want to group records by a certain property. For example, you can group products by their category. We created a server action with a query which returns our records. Open the app connect tab and add app connect to your page (1). Add a new component (2). Add server connect (3-4).
Select your server action (1-3).
Click on your page where you'd like to display your records (1). Add a new component (2). Select repeat region or repeat children region (3-4).
Select the expression for the repeat region (1). Under the server connect component, data, select your query (2). Click the app connect formatter button (3).
Right click your expression (1). Under collections, select "group by" (2-3).
Choose the property to group your records by (1-2).
We want to group our records by category (1). Click select when you're done setting up the group by filter. And click the select button to apply it to the repeat region (2).
Now we can bind the name of the property which we grouped the records by, inside the repeat region.
Just click inside the repeat and add new binding (1-2). Select "key" under the repeat component. This returns the value of the property you are grouping by. In our case, it will show the category name (3-4).
Now, let's add the products grouped under each category.
Click inside the repeat region (1). Add another repeat (2-4).
Select its expression (1). Under the first repeat component in the dynamic data picker dialog, select the value binding (2-3).
Click inside the second repeat which we nested and insert a binding (1-2). Select the binding you want to render inside it. In our case this is the product name (3-4).
And we're done! Now the products will be displayed grouped by their categories. Additionally, you can add the products count in each of the categories.
In order to do this, click after the key binding on the page and insert binding (1-2). Select "value" under the main repeat and click the formatter button (3-4).
Right click the expression and under collection, select count (1-4). Click select in order to insert the binding (5).
And we are done! Let's preview the results.
You can see the products grouped under their categories. Also you can see how many products each of the categories contains. That's how easy it is to use the group by filter.