Skip to content

Commit 4868eac

Browse files
committed
Fix both issues
1 parent 92fdcf0 commit 4868eac

File tree

1 file changed

+56
-54
lines changed
  • samples/grids/pivot-grid/state-persistence-main/src

1 file changed

+56
-54
lines changed

samples/grids/pivot-grid/state-persistence-main/src/index.tsx

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -66,67 +66,68 @@ export default function App() {
6666
let gridStateRef = useRef<IgrGridState>(null);
6767

6868
const pivotConfiguration = new IgrPivotConfiguration();
69+
// column dimensions
70+
const columnDimension = new IgrPivotDimension();
71+
columnDimension.memberName = "SellerName";
72+
columnDimension.enabled = true;
6973

70-
useEffect(() => {
71-
// column dimensions
72-
const columnDimension = new IgrPivotDimension();
73-
columnDimension.memberName = 'SellerName';
74-
columnDimension.enabled = true;
74+
// row dimensions
75+
const productsDimension = new IgrPivotDimension();
76+
const sellerCityDimension = new IgrPivotDimension();
77+
productsDimension.memberName = "ProductName";
78+
productsDimension.enabled = true;
79+
productsDimension.width = "150px";
80+
sellerCityDimension.memberName = "SellerCity";
81+
sellerCityDimension.displayName = "City";
82+
sellerCityDimension.enabled = true;
83+
sellerCityDimension.width = "150px";
7584

76-
// row dimensions
77-
const productsDimension = new IgrPivotDimension();
78-
const sellerCityDimension = new IgrPivotDimension();
79-
productsDimension.memberName = "ProductName";
80-
productsDimension.enabled = true;
81-
productsDimension.width = "150px";
82-
sellerCityDimension.memberName = "SellerCity";
83-
sellerCityDimension.enabled = true;
84-
sellerCityDimension.width = "150px";
85+
// values
86+
const sumAggregator = new IgrPivotAggregator();
87+
sumAggregator.aggregatorName = PivotAggregationType.SUM;
88+
sumAggregator.key = "SUM";
89+
sumAggregator.label = "SUM";
8590

86-
// values
87-
const sumAggregator = new IgrPivotAggregator();
88-
sumAggregator.aggregatorName = PivotAggregationType.SUM;
89-
sumAggregator.key = "SUM";
90-
sumAggregator.label = "SUM";
91+
const totalSaleAggregator = new IgrPivotAggregator();
92+
totalSaleAggregator.aggregator = totalSale;
93+
totalSaleAggregator.label = "Sum of Sale";
94+
totalSaleAggregator.key = "SUM";
95+
const minimumSaleAggregator = new IgrPivotAggregator();
96+
minimumSaleAggregator.aggregator = totalMin;
97+
minimumSaleAggregator.label = "Minimum of Sale";
98+
minimumSaleAggregator.key = "MIN";
99+
const maximumSaleAggregator = new IgrPivotAggregator();
100+
maximumSaleAggregator.aggregator = totalMax;
101+
maximumSaleAggregator.label = "Maximum of Sale";
102+
maximumSaleAggregator.key = "MAX";
91103

92-
const totalSaleAggregator = new IgrPivotAggregator();
93-
totalSaleAggregator.aggregator = totalSale;
94-
totalSaleAggregator.label = "Sum of Sale";
95-
totalSaleAggregator.key = "SUM";
96-
const minimumSaleAggregator = new IgrPivotAggregator();
97-
minimumSaleAggregator.aggregator = totalMin;
98-
minimumSaleAggregator.label = "Minimum of Sale";
99-
minimumSaleAggregator.key = "MIN";
100-
const maximumSaleAggregator = new IgrPivotAggregator();
101-
maximumSaleAggregator.aggregator = totalMax;
102-
maximumSaleAggregator.label = "Maximum of Sale";
103-
maximumSaleAggregator.key = "MAX";
104+
const value = new IgrPivotValue();
105+
value.enabled = true;
106+
value.member = "Value";
107+
value.aggregate = sumAggregator;
108+
value.styles = {
109+
downFontValue: (rowData: any, columnKey: any): boolean =>
110+
parseFloat(rowData.aggregationValues.get(columnKey.field)) <= 150,
111+
upFontValue: (rowData: any, columnKey: any): boolean =>
112+
parseFloat(rowData.aggregationValues.get(columnKey.field)) > 150,
113+
};
104114

105-
const value = new IgrPivotValue();
106-
value.enabled = true;
107-
value.member = "Value";
108-
value.aggregate = sumAggregator;
109-
value.styles = {
110-
downFontValue: (rowData: any, columnKey: any): boolean =>
111-
parseFloat(rowData.aggregationValues.get(columnKey.field)) <= 150,
112-
upFontValue: (rowData: any, columnKey: any): boolean =>
113-
parseFloat(rowData.aggregationValues.get(columnKey.field)) > 150,
114-
};
115+
const amountOfSale = new IgrPivotValue();
116+
amountOfSale.enabled = true;
117+
amountOfSale.member = "AmountofSale";
118+
amountOfSale.displayName = "Amount of Sale";
119+
amountOfSale.aggregate = totalSaleAggregator;
120+
amountOfSale.aggregateList = [
121+
totalSaleAggregator,
122+
minimumSaleAggregator,
123+
maximumSaleAggregator,
124+
];
115125

116-
const amountOfSale = new IgrPivotValue();
117-
amountOfSale.enabled = true;
118-
amountOfSale.member = "AmountofSale";
119-
amountOfSale.displayName = "Amount of Sale";
120-
amountOfSale.aggregate = totalSaleAggregator;
121-
amountOfSale.aggregateList = [
122-
totalSaleAggregator,
123-
minimumSaleAggregator,
124-
maximumSaleAggregator,
125-
];
126+
pivotConfiguration.columns = [columnDimension];
127+
pivotConfiguration.rows = [productsDimension, sellerCityDimension];
128+
pivotConfiguration.values = [value, amountOfSale];
126129

127-
pivotConfiguration.columns = [columnDimension];
128-
pivotConfiguration.rows = [productsDimension, sellerCityDimension];
129-
pivotConfiguration.values = [value, amountOfSale];
130+
useEffect(() => {
130131
registerIconFromText("restore", restoreIcon, "material");
131132
registerIconFromText("save", saveIcon, "material");
132133
registerIconFromText("clear", clearIcon, "material");
@@ -335,6 +336,7 @@ export default function App() {
335336
height="500px"
336337
pivotConfiguration={pivotConfiguration}
337338
valueInit={onValueInit}
339+
superCompactMode="true"
338340
columnSelection={GridSelectionMode.Single}
339341
cellSelection={GridSelectionMode.Single}
340342
>

0 commit comments

Comments
 (0)