@@ -53,7 +53,7 @@ export class IgxPivotDateDimension implements IPivotDimension {
53
53
*/
54
54
public dataType ?: GridColumnDataType ;
55
55
56
- /** Default options used for initialization . */
56
+ /** Default options. */
57
57
public defaultOptions = {
58
58
total : true ,
59
59
years : true ,
@@ -75,11 +75,57 @@ export class IgxPivotDateDimension implements IPivotDimension {
75
75
return this . _resourceStrings ;
76
76
}
77
77
78
+ /**
79
+ * Gets/Sets the base dimension that is used by this class to determine the other dimensions and their values.
80
+ * Having base dimension set is required in order for the Date Dimensions to show.
81
+ */
82
+ public get baseDimension ( ) : IPivotDimension {
83
+ return this . _baseDimension ;
84
+ }
85
+ public set baseDimension ( value : IPivotDimension ) {
86
+ this . _baseDimension = value ;
87
+ this . initialize ( this . baseDimension , this . options ) ;
88
+ }
89
+
90
+ /**
91
+ * Gets/Sets the options for the predefined date dimensions whether to show quarter, years and etc.
92
+ */
93
+ public get options ( ) : IPivotDateDimensionOptions {
94
+ return this . _options ;
95
+ }
96
+ public set options ( value : IPivotDateDimensionOptions ) {
97
+ this . _options = value ;
98
+ if ( this . baseDimension ) {
99
+ this . initialize ( this . baseDimension , this . options ) ;
100
+ }
101
+ }
102
+
103
+ /**
104
+ * @deprecated since version 15.1.x. Please use the new name `baseDimension` for future versions.
105
+ *
106
+ * Gets the base dimension that is used by this class to determine the other dimensions and their values.
107
+ * Having base dimension set is required in order for the Date Dimensions to show.
108
+ */
109
+ public get inBaseDimension ( ) : IPivotDimension {
110
+ return this . _baseDimension ;
111
+ }
112
+
113
+ /**
114
+ * @deprecated since version 15.1.x. Please use the new name `options` for future versions.
115
+ *
116
+ * Gets the options for the predefined date dimensions whether to show quarter, years and etc.
117
+ */
118
+ public get inOptions ( ) : IPivotDateDimensionOptions {
119
+ return this . _options ;
120
+ }
121
+
78
122
/** @hidden @internal */
79
123
public childLevel ?: IPivotDimension ;
80
124
/** @hidden @internal */
81
125
public memberName = 'AllPeriods' ;
82
126
private _resourceStrings = CurrentResourceStrings . GridResStrings ;
127
+ private _baseDimension : IPivotDimension ;
128
+ private _options : IPivotDateDimensionOptions = { } ;
83
129
private _monthIntl = new Intl . DateTimeFormat ( 'default' , { month : 'long' } ) ;
84
130
85
131
/**
@@ -93,13 +139,16 @@ export class IgxPivotDateDimension implements IPivotDimension {
93
139
* new IgxPivotDateDimension({ memberName: 'Date', enabled: true }, { total: false, months: false });
94
140
* ```
95
141
*/
96
- constructor ( public inBaseDimension : IPivotDimension , public inOptions : IPivotDateDimensionOptions = { } ) {
97
- const options = { ...this . defaultOptions , ...inOptions } ;
98
-
99
- if ( ! inBaseDimension ) {
100
- console . warn ( `Please provide data child level to the pivot dimension.` ) ;
101
- return ;
142
+ constructor ( inBaseDimension : IPivotDimension , inOptions : IPivotDateDimensionOptions = { } ) {
143
+ this . _baseDimension = inBaseDimension ;
144
+ this . _options = inOptions ;
145
+ if ( this . baseDimension && this . options ) {
146
+ this . initialize ( this . baseDimension , this . options ) ;
102
147
}
148
+ }
149
+
150
+ protected initialize ( inBaseDimension , inOptions ) {
151
+ const options = { ...this . defaultOptions , ...inOptions } ;
103
152
104
153
this . dataType = GridColumnDataType . Date ;
105
154
inBaseDimension . dataType = GridColumnDataType . Date ;
0 commit comments