groupBy

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

void groupBy(string|function param);

Parameters

paramstring|functionthe 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 samples

Details

The method takes one parameter, which can be:

  • id - (string) 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.

See also
Change log

added in v6.5

Back to top