Skip to content

Grouping

getGroupingData

Extracts grouping data from the store for a specific row

@param store - The data store * @param itemIndex - The index of the current item * @param currentDepth - The current depth of the grouping * @param columnProp - The column property to aggregate * @param aggregator - The aggregation function to apply * @returns An object containing the count, values, and aggregation result

export function getGroupingData(;

GroupingAggregationTemplate

The GroupingAggregationTemplate type defines the structure of aggregation functions that can be used for grouping in a RevoGrid.

/**
* The `GroupingAggregationTemplate` type defines the structure of aggregation functions
* that can be used for grouping in a RevoGrid.
*/
export type GroupingAggregationTemplate = {
aggregations?: { [key: string]: (values: any[]) => any };
}

GroupingData

The GroupingData type defines the structure of data returned by the getGroupingData function

/**
* The `GroupingData` type defines the structure of data returned by the getGroupingData function
*/
export type GroupingData = {
count: number;
values: DataType[];
aggregationValue: any;
};

groupingAggregation

The groupingAggregation function is a template for creating custom aggregation functions that can be used for grouping in a RevoGrid.

This function takes a template object with an optional aggregations property, which is a key-value pair where the key is the column property name and the value is an aggregation function. The aggregation functions receive an array of values and return a single aggregated result.

Example

const aggregations = {
'name': (values: string[]) => values.join(', ')
}
const template: GroupLabelTemplateFunc = (h, props) => {
return groupingAggregation(h, props, aggregations);
}
const grid = document.createElement('revo-grid');
grid.columns = [
{ prop: 'name', name: 'Name', template: template }
]
groupingAggregation: GroupLabelTemplateFunc;