devexpress-reporting
Version:
DevExpress Reporting provides the capability to develop a reporting application to create and customize reports.
58 lines (57 loc) • 2.39 kB
JavaScript
/**
* DevExpress HTML/JS Reporting (designer\controls\properties\sortingOptions.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 { extend } from '@devexpress/analytics-core/analytics-internal-native';
import { Disposable, ModelSerializer } from '@devexpress/analytics-core/analytics-utils';
import * as ko from 'knockout';
import { sortingOptionsSerializationsInfo } from '../metadata/properties/sortingOptions';
export class SortingOptions extends Disposable {
_getFieldNames(targetBand) {
const fieldArray = targetBand && (targetBand['sortFields'] || targetBand['groupFields']);
return fieldArray ? fieldArray().map(item => item.fieldName()).filter(name => !!name) : [];
}
getInfo() {
return this._info;
}
isPropertyDisabled(name) {
return name == 'fieldName' && !this.targetBand();
}
resetValue() {
this.targetBand(null);
this.fieldName('');
}
constructor(model, report, serializer) {
super();
this._info = extend(true, [], sortingOptionsSerializationsInfo);
this._fieldNameInfo = this._info.filter((info) => { return info.propertyName == 'fieldName'; })[0];
serializer = serializer || new ModelSerializer();
serializer.deserialize(this, model || {});
Object.defineProperty(this._fieldNameInfo, 'valuesArray', {
get: () => {
let items = [];
const currentBand = this.targetBand && this.targetBand();
if (currentBand) {
items = this._getFieldNames(currentBand).map(fieldName => { return { value: fieldName, displayValue: fieldName }; });
}
return items;
}
});
const _fieldName = this.fieldName;
this._disposables.push(this.fieldName = ko.computed({
read: () => {
const value = _fieldName();
return this._getFieldNames(this.targetBand()).indexOf(value) === -1 ? '' : value;
},
write: (newValue) => {
_fieldName(newValue);
}
}));
}
getPath(propertyName) {
return this.targetBand() && this.targetBand().getPath('groupFields') || '';
}
}