groupBy()
groups grid content either by values of the specified column or by the result of calculation
groupBy(property: string | ((item: IDataItem) => string)): void;
Parameters:
property: string | function
- the id of the column or the rule of grouping
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
The method takes one parameter, which can be:
- id - (string, number) the id of the column
- a function with a rule of grouping data.The function returns the name of a group and takes one parameter:
- item - a data item
You can set a template to the title of the group via the groupTitleTemplate configuration option.
Change log:
added in v6.5