Skip to main content

groupBy()

groups grid content either by values of the specified column or by the result of calculation

groupBy(property: string | ((item: object) => string)): void;

Parameters:

  • property: string | function - either the id of the column or a function with the rule of grouping data. The function returns the name of a group and takes a data item as a parameter.

Example

//Grouping by values of the specified column
treegrid.groupBy("age");

//Grouping by the result of calculation
treegrid.groupBy(function (item) {
if (!item.area || item.area < 0) {
return "N.A.";
}
if (item.area < 25000) {
return "Small";
} else if (item.area < 60000) {
return "Medium";
}
return "Big";
});

Related sample: TreeGrid. Group data items by a property

You can set a template to the title of the group via the groupTitleTemplate configuration option.

Change log:

added in v6.5