igniteui-react-grids
Version:
Ignite UI React grid components.
191 lines (190 loc) • 5.08 kB
JavaScript
import { IgrFilteringExpressionsTree } from "./igr-filtering-expressions-tree";
import { SortingDirection_$type } from "./SortingDirection";
import { GridColumnDataType_$type } from "./GridColumnDataType";
import { PivotDimension as PivotDimension_internal } from "./PivotDimension";
import { ensureBool, ensureEnum } from "igniteui-react-core";
/**
* Configuration of a pivot dimension.
*/
export class IgrPivotDimension {
createImplementation() {
let impl = new PivotDimension_internal();
if (impl.setNativeElement) {
impl.setNativeElement({});
}
return impl;
}
get nativeElement() {
return this._implementation.nativeElement;
}
/**
* @hidden
*/
get i() {
return this._implementation;
}
onImplementationCreated() {
}
constructor() {
this.mounted = false;
this._implementation = this.createImplementation();
this._implementation.externalObject = this;
this.onImplementationCreated();
if (this._initializeAdapters) {
this._initializeAdapters();
}
}
_provideImplementation(i) {
this._implementation = i;
this._implementation.externalObject = this;
this.onImplementationCreated();
if (this._initializeAdapters) {
this._initializeAdapters();
}
}
/**
* Allows defining a hierarchy when multiple sub groups need to be extracted from single member.
*/
get childLevel() {
const r = this.i.d;
if (r == null) {
return null;
}
if (!r.externalObject) {
let e = new IgrPivotDimension();
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(r);
}
}
r.externalObject = e;
}
return r.externalObject;
}
set childLevel(v) {
v == null ? this.i.d = null : this.i.d = v.i;
}
/**
* Field name to use in order to extract value.
*/
get memberName() {
return this.i.o;
}
set memberName(v) {
this.i.o = v;
}
/**
* Display name to show instead of the field name of this value. *
*/
get displayName() {
return this.i.n;
}
set displayName(v) {
this.i.n = v;
}
/**
* Enables/Disables a particular dimension from pivot structure.
*/
get enabled() {
return this.i.h;
}
set enabled(v) {
this.i.h = ensureBool(v);
}
/**
* A predefined or defined via the `igxPivotSelector` filter expression tree for the current dimension to be applied in the filter pipe.
*/
get filter() {
const r = this.i.a;
if (r == null) {
return null;
}
if (!r.externalObject) {
let e = new IgrFilteringExpressionsTree();
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(r);
}
}
r.externalObject = e;
}
return r.externalObject;
}
set filter(v) {
v == null ? this.i.a = null : this.i.a = v.i;
}
/**
* Enable/disable sorting for a particular dimension. True by default.
*/
get sortable() {
return this.i.j;
}
set sortable(v) {
this.i.j = ensureBool(v);
}
/**
* The sorting direction of the current dimension. Determines the order in which the values will appear in the related dimension.
*/
get sortDirection() {
return this.i.e;
}
set sortDirection(v) {
this.i.e = ensureEnum(SortingDirection_$type, v);
}
/**
* The dataType of the related data field.
*/
get dataType() {
return this.i.b;
}
set dataType(v) {
this.i.b = ensureEnum(GridColumnDataType_$type, v);
}
/**
* The width of the dimension cells to be rendered.Can be pixel, % or "auto".
*/
get width() {
return this.i.p;
}
set width(v) {
this.i.p = v;
}
/**
* Level of the dimension.
*/
get level() {
return this.i.k;
}
set level(v) {
this.i.k = +v;
}
get horizontalSummary() {
return this.i.i;
}
set horizontalSummary(v) {
this.i.i = ensureBool(v);
}
findByName(name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
if (this.childLevel && this.childLevel.name && this.childLevel.name == name) {
return this.childLevel;
}
if (this.filter && this.filter.name && this.filter.name == name) {
return this.filter;
}
return null;
}
setNativeElement(element) {
this.i.setNativeElement(element);
}
}