Cell Summary Operation

User Function which allows users to provide their own Cell Summary operations.

Definition

handler: (operationParam: {
selectedCellInfo: SelectedCellInfo;
allValues: any[];
numericColumns: string[];
numericValues: number[];
distinctCount: number;
}) => any;

The Function receives the following information about what is currently selected:

  • a Selected Cell Info object
  • list of values
  • numeric columns
  • numeric values and much else
  • count of selected items

It should return a single value to be displayed in the dropdown.

Example

// Predefined Config
export default {
CellSummary: {
CellSummaryOperationDefinitions: [
{
OperationName: 'Oldest',
OperationFunction: 'OldestOperationFunction',
},
],
},
} as PredefinedConfig;
// Adaptable Options
const adaptableOptions: AdaptableOptions = {
userFunctions: [
{
type: 'CellSummaryOperationFunction',
name: 'OldestOperationFunction',
handler(operationParam) {
let dateValues: Date[] = [];
operationParam.selectedCellInfo.Columns.filter(
c => c.DataType === 'Date'
).forEach(dc => {
let gridCells = operationParam.selectedCellInfo.GridCells.filter(
gc => gc.columnId == dc.ColumnId
).map(gc => gc.rawValue);
dateValues.push(...gridCells);
});
if (dateValues.length > 0) {
const sortedDates = dateValues.sort((a, b) => {
return new Date(a).getTime() - new Date(b).getTime();
});
return new Date(sortedDates[0]).toLocaleDateString();
}
},
},
}