Edit this page

group

Gets or sets the grouping configuration.

Parameters

value Object |Array

The grouping configuration. Accepts the same values as the group option.

Returns

Array the current grouping configuration.

Example - group the data items

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Tea", category: "Beverages" },
    { name: "Coffee", category: "Beverages" },
    { name: "Ham", category: "Food" }
  ]
});
dataSource.group({ field: "category" });
var view = dataSource.view();
console.log(view.length); // displays "2"
var beverages = view[0];
console.log(beverages.value); // displays "Beverages"
console.log(beverages.items[0].name); // displays "Tea"
console.log(beverages.items[1].name); // displays "Coffee"
var food = view[1];
console.log(food.value); // displays "Food"
console.log(food.items[0].name); // displays "Ham"
</script>

Example - get the data source grouping configuration

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Tea", category: "Beverages" },
    { name: "Coffee", category: "Beverages" },
    { name: "Ham", category: "Food" }
  ],
  group: { field: "category" }
});
var groups = dataSource.group();
console.log(groups.length); // displays "1"
console.log(groups[0].field); // displays "category"
</script>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy