@@ -66,8 +66,9 @@ import { ref } from 'vue';
6666import DxPivotGrid , {
6767 DxFieldChooser ,
6868 DxFieldPanel ,
69+ type DxPivotGridTypes ,
6970} from ' devextreme-vue/pivot-grid' ;
70- import DxCheckBox from ' devextreme-vue/check-box' ;
71+ import DxCheckBox , { type DxCheckBoxTypes } from ' devextreme-vue/check-box' ;
7172import PivotGridDataSource from ' devextreme/ui/pivot_grid/data_source' ;
7273import { sales } from ' ./data.ts' ;
7374
@@ -86,7 +87,7 @@ const gridDataSource = new PivotGridDataSource({
8687 dataField: ' city' ,
8788 width: 150 ,
8889 area: ' row' ,
89- selector(data ) {
90+ selector(data : Record < string , unknown > ) {
9091 return ` ${data .city } (${data .country }) ` ;
9192 },
9293 }, {
@@ -103,36 +104,34 @@ const gridDataSource = new PivotGridDataSource({
103104 store: sales ,
104105});
105106
106- function OnShowColumnFieldsChanged(e ) {
107+ function OnShowColumnFieldsChanged(e : DxCheckBoxTypes . ValueChangedEvent ) {
107108 showColumnFields .value = e .value ;
108109}
109- function OnShowDataFieldsChanged(e ) {
110+ function OnShowDataFieldsChanged(e : DxCheckBoxTypes . ValueChangedEvent ) {
110111 showDataFields .value = e .value ;
111112}
112- function OnShowFilterFieldsChanged(e ) {
113+ function OnShowFilterFieldsChanged(e : DxCheckBoxTypes . ValueChangedEvent ) {
113114 showFilterFields .value = e .value ;
114115}
115- function OnShowRowFieldsChanged(e ) {
116+ function OnShowRowFieldsChanged(e : DxCheckBoxTypes . ValueChangedEvent ) {
116117 showRowFields .value = e .value ;
117118}
118- function onContextMenuPreparing(e ) {
119+ function onContextMenuPreparing(e : DxPivotGridTypes . ContextMenuPreparingEvent ) {
119120 const dataSource = e .component .getDataSource ();
120- const sourceField = e .field ;
121+ const sourceField: Record < string , any > | undefined = e .field ;
121122
122123 if (sourceField ) {
123124 if (! sourceField .groupName || sourceField .groupIndex === 0 ) {
124- e .items .push ({
125+ e .items ? .push ({
125126 text: ' Hide field' ,
126127 onItemClick() {
127128 let fieldIndex: number ;
128129
129- if (sourceField .groupName ) {
130- fieldIndex = dataSource
131- .getAreaFields (sourceField .area , true )[sourceField .areaIndex ]
132- .index ;
133- } else {
134- fieldIndex = sourceField .index ;
135- }
130+ const dataSourceField: Record <string , any > = sourceField .groupName
131+ ? dataSource .getAreaFields (sourceField .area , true )[sourceField .areaIndex ]
132+ : sourceField
133+
134+ fieldIndex = dataSourceField .index ;
136135
137136 dataSource .field (fieldIndex , {
138137 area: null ,
@@ -143,7 +142,7 @@ function onContextMenuPreparing(e) {
143142 }
144143
145144 if (sourceField .dataType === ' number' ) {
146- const setSummaryType = function (args ) {
145+ const setSummaryType = function (args : Record < string , any > ) {
147146 dataSource .field (sourceField .index , {
148147 summaryType: args .itemData .value ,
149148 });
@@ -152,7 +151,7 @@ function onContextMenuPreparing(e) {
152151 };
153152 const menuItems: Record <string , any >[] = [];
154153
155- e .items .push ({ text: ' Summary Type' , items: menuItems });
154+ e .items ? .push ({ text: ' Summary Type' , items: menuItems });
156155
157156 [' Sum' , ' Avg' , ' Min' , ' Max' ].forEach ((summaryType ) => {
158157 const summaryTypeValue = summaryType .toLowerCase ();
@@ -161,7 +160,7 @@ function onContextMenuPreparing(e) {
161160 text: summaryType ,
162161 value: summaryType .toLowerCase (),
163162 onItemClick: setSummaryType ,
164- selected: e .field .summaryType === summaryTypeValue ,
163+ selected: e .field ? .summaryType === summaryTypeValue ,
165164 });
166165 });
167166 }
0 commit comments