Grouping¶
Grouping of the list items.
When assigning a rule to a property of Grouping, the rule will be passed an instance of the following proxy class as an argument:
Grouping Properties¶
| Property | Type | Required |
|---|---|---|
| GroupingProperties | complex | No |
| Header | object |
No |
GroupingProperties¶
An array of EntitySet property names used to group list items, or a Rule that returns such an array. Property names not present in the EntitySet are ignored. These properties are automatically added at the front of the OData $orderby clause. Additional sort keys defined in QueryOptions of Target are appended after them, with deduplication if a grouping property is already present. Ensure that these fields are requested via the OData $select in the QueryOptions of Target so that they are returned by the query.
- type: complex
GroupingProperties Value¶
Any following options needs to be fulfilled.
Option 1¶
Array type:
All items must be of the type:
string
Option 2¶
Expects return of GroupingProperties in array format.
Header¶
Configuration for the header displayed above each grouped section. Define one or more GroupingItem entries in
Items. If multiple are provided, only the first is used for rendering. Alternatively, Items can be a Rule that
returns an array of GroupingItem objects. Only the first returned item will be rendered.
- type:
objectwith following properties.
| Property | Type | Required | Default |
|---|---|---|---|
Items |
complex | No |
Items¶
Examples¶
Simple grouping — no additional sort keys¶
MDK injects GroupingProperties into $orderby automatically, so no orderby is needed in QueryOptions.
"Grouping": {
"GroupingProperties": ["Country"],
"Header": {
"Items": [{
"Title": "Country: {Country}",
"Styles": {
"Title": "DataTableGroupHeaderItem",
"BackgroundColor": "sectionBgColor"
}
}]
}
},
...
"Target": {
"EntitySet": "MyWorkOrderHeaders",
"Service": "/MDKDevApp/Services/Amw.service"
}
Resulting OData query: $orderby=Country
Grouping with secondary sort keys¶
GroupingProperties are prepended to the $orderby. Additional sort keys in QueryOptions are appended after them.
"Grouping": {
"GroupingProperties": ["Country", "City"],
"Header": {
"Items": [{
"Title": "Group Country - {Country}, City - {City}",
"Styles": {
"Title": "DataTableGroupHeaderItem",
"BackgroundColor": "sectionBgColor"
}
}]
}
},
...
"Target": {
"EntitySet": "MyWorkOrderHeaders",
"Service": "/MDKDevApp/Services/Amw.service",
"QueryOptions": "$orderby=LastName,FirstName"
}
Resulting OData query: $orderby=Country,City,LastName,FirstName
Style Classes Definition¶
.DataTableGroupHeaderItem {
font-color: #ff0000;
font-style: body; /*iOS only*/
}
.sectionBgColor {
background-color: @mdkYellow1;
}