Documentation

group

groups data by the specified data property

void group(object config,boolean mode);

Parameters

configobjectan object with grouping parameters
modebooleandefines whether the component should be re-rendered after grouping ( by default, true)

See also

Example

myview.group({
    by:"#company#", // 'company' is the name of data property
    map:{
        sales:["#sales#","sum"]
    }   
});

Details

The method is called for each data item.

The config object has 2 properties:

  • by – a data property according which items will be united in groups
  • map – an object that specifies new data properties that the items in a group will have. Properties are specified by an array. The first element of this array is a template with a property from original data, the second one – the functor that will be applied to all values of the property (set by the first element) in the group.
    Grouping provides the following functors:

    • sum – gets the sum of values in a group;
    • max – gets the maximum value in a group;
    • min - gets the minimum value in a group;
    • count - gets the number of items in a group;
    • any - gets a random property value from a group;
    • string - adds a custom data property to group items.

      It’s possible to define custom functor. Read on the topic in the related article - 'Custom Functor for Data Grouping'.


To group data initially (just after data has been loaded) you may use the scheme parameter, to be accurate, its $group key.

webix.ui({
    view:"chart",
    ...
    scheme:{
        $group:{
            by:"#company#", // 'company' is the name of data property
            map:{
                sales:["#sales#","sum"],
                state:["grouped","string"]
            }   
        }
    }
});
Back to top