I am using the helper function process, like this example
https://www.telerik.com/kendo-react-ui/components/dataquery/bulk-operations/
const data = [
{ "productName": "Chai", "unitPrice": 18, "unitsInStock": 39, "discontinued": false,
"category": { "categoryName": "Beverages" }
},
{ "productName": "Chang", "unitPrice": 19, "unitsInStock": 17, "discontinued": false,
"category": { "categoryName": "Beverages" }
},
{ "productName": "Aniseed Syrup", "unitPrice": 10, "unitsInStock": 13, "discontinued": false,
"category": { "categoryName": "Condiments" }
},
{ "productName": "Cajun Seasoning", "unitPrice": 22, "unitsInStock": 53, "discontinued": false,
"category": { "categoryName": "Condiments" }
},
{ "productName": "Gumbo Mix", "unitPrice": 21.35, "unitsInStock": 0, "discontinued": true,
"category": { "categoryName": "Condiments" }
}
];
const result = process(data, {
group: [{
field: 'category.categoryName',
aggregates: [
{ aggregate: "sum", field: "unitPrice" },
{ aggregate: "sum", field: "unitsInStock" }
]
}],
sort: [{ field: 'productName', dir: 'desc' }],
filter: {
logic: "or",
filters: [
{ field: "discontinued", operator: "eq", value: true },
{ field: "unitPrice", operator: "lt", value: 22 }
]
}
});
I am expecting the result like the example
{
"data": [
{ "aggregates": {
"unitPrice": { "sum": 53.35 },
"unitsInStock": { "sum": 66 }
},
"field": "category.categoryName",
"items": [
{ "productName": "Gumbo Mix", "unitPrice": 21.35, "unitsInStock": 0, "discontinued": true,
"category": { "categoryName": "Condiments" }
},
{ "productName": "Aniseed Syrup", "unitPrice": 10, "unitsInStock": 13, "discontinued": false,
"category": { "categoryName": "Condiments" }
}
],
"value": "Condiments"
},
{
"aggregates": {
"unitPrice": { "sum": 37 },
"unitsInStock": { "sum": 56 }
},
"field": "category.categoryName",
"items": [
{ "productName": "Chang", "unitPrice": 19, "unitsInStock": 17, "discontinued": false,
"category": { "categoryName": "Beverages" }
},
{ "productName": "Chai", "unitPrice": 18, "unitsInStock": 39, "discontinued": false,
"category": { "categoryName": "Beverages" }
}
],
"value": "Beverages"
}
],
"total": 4
}
But I actually got this, which is not ordering by the product name, but order by the category name and then product name
{
data: [
{
aggregates: {
unitPrice: {
sum: 37,
},
unitsInStock: {
sum: 56,
},
},
field: "category.categoryName",
items: [
{
productName: "Chang",
unitPrice: 19,
unitsInStock: 17,
discontinued: false,
category: {
categoryName: "Beverages",
},
},
{
productName: "Chai",
unitPrice: 18,
unitsInStock: 39,
discontinued: false,
category: {
categoryName: "Beverages",
},
},
],
value: "Beverages",
},
{
aggregates: {
unitPrice: {
sum: 31.35,
},
unitsInStock: {
sum: 13,
},
},
field: "category.categoryName",
items: [
{
productName: "Gumbo Mix",
unitPrice: 21.35,
unitsInStock: 0,
discontinued: true,
category: {
categoryName: "Condiments",
},
},
{
productName: "Aniseed Syrup",
unitPrice: 10,
unitsInStock: 13,
discontinued: false,
category: {
categoryName: "Condiments",
},
},
],
value: "Condiments",
},
],
total: 4,
}
How can I achieve the result in the example?