devexpress-reporting
Version:
DevExpress Reporting provides the capability to develop a reporting application to create and customize reports.
74 lines (73 loc) • 3.94 kB
JavaScript
/**
* DevExpress HTML/JS Reporting (viewer\widgets\_multiValueEditor.js)
* Version: 25.1.3
* Build date: Jun 26, 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 {
constructor() {
super(...arguments);
this._multiValueEditorSubscriptions = [];
}
_createMultiValueEditorValueViewModel(currentValue) {
this._multiValueEditorSubscriptions.forEach(x => x());
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();
this._multiValueEditorSubscriptions.push(this.subscribeProperty('disabled', (x) => viewModel.disabled = x), this.subscribeProperty('displayName', (x) => 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();
viewModel.value = this._createMultiValueEditorValueViewModel(this._get('value'));
}));
return viewModel;
}
dispose() {
super.dispose();
this._multiValueEditorSubscriptions.forEach(x => x());
this._multiValueEditorSubscriptions = [];
}
}