UNPKG

devexpress-reporting

Version:

DevExpress Reporting provides the capability to develop a reporting application to create and customize reports.

69 lines (68 loc) 3.78 kB
/** * DevExpress HTML/JS Reporting (viewer\widgets\_multiValueEditor.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 { createViewModelGenerator } from '@devexpress/analytics-core/analytics-serializer-native'; import { getLocalization } from '@devexpress/analytics-core/analytics-utils-native'; import { Editor } from '@devexpress/analytics-core/analytics-widgets-native'; import { formatUnicorn, getParentContainer, selectPlaceholder } from '@devexpress/analytics-core/analytics-internal-native'; export class MultiValueEditor extends Editor { _createMultiValueEditorValueViewModel(currentValue) { const viewModel = createViewModelGenerator() .createDefaultModel(currentValue) .generateProperty('value', currentValue.value) .generateProperty('disabled', this._get('disabled')) .generateProperty('displayName', this._get('displayName')) .generateProperty('dataSource', currentValue.dataSource) .generateProperty('items', currentValue.items) .generateProperty('displayExpr', 'displayValue') .generateProperty('editorInputId', this.editorInputId) .generateProperty('getOptions', (options) => { return { ...this.getOptions(options), onValueChanged: (e) => { currentValue.value = e.value; }, onMultiTagPreparing: (args) => { const selectedItemsLength = args.selectedItems.length, totalCount = currentValue.items.length; if (selectedItemsLength === totalCount) { const stringFormat = getLocalization('All selected ({0})', 'ASPxReportsStringId.WebDocumentViewer_MultiValueEditor_AllSelected'); args.text = formatUnicorn(stringFormat, selectedItemsLength); } } }; }) .generateProperty('getPopupContainer', getParentContainer) .generateProperty('maxDisplayedTags', currentValue.maxDisplayedTags) .generateProperty('placeholder', selectPlaceholder()) .generateProperty('searchExpr', ['displayValue']) .generateProperty('selectAllText', getLocalization('Select All', 'AnalyticsCoreStringId.SelectAll')) .generateProperty('getValidatorOptions', (options) => this.getValidatorOptions(options)) .generateProperty('validatorOptions', this.unwrap(this.validatorOptions)) .generateProperty('validationRules', this.validationRules) .generateProperty('valueExpr', 'value') .getViewModel(); currentValue.addDisposable(this.subscribeProperty('disabled', (x) => viewModel && (viewModel.disabled = x)), this.subscribeProperty('displayName', (x) => viewModel && (viewModel.displayName = x))); return viewModel; } createViewModel() { const currentValue = this._get('value'); const viewModel = createViewModelGenerator(super.createViewModel()) .generateProperty('value', this._createMultiValueEditorValueViewModel(currentValue)) .getViewModel(); this.destroyPropertySubscription('value'); this.addDisposable(this.subscribeProperty('value', (x) => { const viewModel = this.getViewModel(); const currentValue = this._get('value'); if (viewModel && !currentValue.isDisposing) viewModel.value = this._createMultiValueEditorValueViewModel(currentValue); })); return viewModel; } dispose() { super.dispose(); } }