devexpress-reporting
Version:
DevExpress Reporting provides the capability to develop a reporting application to create and customize reports.
55 lines (54 loc) • 2.42 kB
JavaScript
/**
* DevExpress HTML/JS Reporting (designer\utils\_registerCustomExpressions.js)
* Version: 25.2.3
* Build date: Dec 15, 2025
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* License: https://www.devexpress.com/Support/EULAs/universal.xml
*/
import { functionDisplay, insertOrUpdateFunctions } from '@devexpress/analytics-core/analytics-widgets-internal';
import { expressionFunctions } from '@devexpress/analytics-core/queryBuilder-widgets-internal';
import { reportFunctionDisplay } from '../widgets/customFunctions';
import { extend } from '@devexpress/analytics-core/analytics-internal';
import { DefaultFilterEditorHelper } from '@devexpress/analytics-core/analytics-widgets';
export function registerCustomGlobalExpressions(expressions) {
if (!expressions?.length) {
return;
}
const helper = DefaultFilterEditorHelper();
expressions.forEach((expressionInfo) => {
const expression = translateExpression(expressionInfo);
insertOrUpdateFunctions(functionDisplay(), [extend(true, {}, expression)]);
insertOrUpdateFunctions(expressionFunctions, [extend(true, {}, expression)]);
insertOrUpdateFunctions(reportFunctionDisplay, [extend(true, {}, expression)]);
helper.addCustomExpression({
description: expressionInfo.description,
category: expressionInfo.category,
name: expressionInfo.name,
});
});
}
export function registerCustomReportExpressions(expressions) {
if (!expressions?.length) {
return;
}
expressions.forEach((expressionInfo) => {
const expression = translateExpression(expressionInfo);
insertOrUpdateFunctions(reportFunctionDisplay, [expression]);
});
}
const translateExpression = (expression) => {
const editorText = `${expression.name}(${Array.from({ length: expression.maxOperandCount }, () => '').join(', ')})`;
const editorPrefix = expression.category === 'Aggregate' ? '[].' : '';
const categoryName = expression.category ?? 'Custom';
return {
display: categoryName,
items: {
[expression.name]: [{
paramCount: Math.max(expression.maxOperandCount, 0),
text: `${editorPrefix}${editorText}`,
displayName: editorText,
description: expression.description
}],
}
};
};