On this page
Pivoting

Row Aggregations

LyteNyte Grid uses the aggModel on grid state to determine how to create aggregations for rows. Aggregations are used for the calculation of the data for group rows. Normal leaf rows do not have aggregated data - since by definition the leaf rows are used to make up the aggregated data.

Row Grouping

Aggregation Model

The aggModel is an object, where each key corresponds to a key on the final aggregation output. The aggregation output must be an object of key value pairs. Normally the key is the id of a column but this is not a requirement.

Each aggModel value is an object with a fn key. The fn key is used to determine which aggregation to apply for the final aggregation output. LyteNyte Grid provides some built-in aggregation functions, but you may also define your own.

The full type of the aggModel is showing below:

export type AggBuiltIns =
  | "sum"
  | "min"
  | "max"
  | "avg"
  | "count"
  | "first"
  | "last"
  | "group";
 
export type AggModel = {
  [columnId: string]: {
    fn: AggBuiltIns | (string & {}) | AggFn;
  };
};

Aggregations are calculated by the row data source being used. The client row data source will perform aggregation calculations on the client, whilst the server row data source will perform them on the server. Not every column must have a aggregation applied - and for many columns it makes sense for no aggregation to be applied.