Skip to content

Commit d52fec3

Browse files
authored
Add missing auto get section and pivot keys add in overview. (#1402)
1 parent f2ed1ad commit d52fec3

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

doc/en/components/grids/pivot-grid/overview.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,98 @@ Using above code will result in the following example which groups the Date uniq
570570
571571
`sample="/{PivotGridSample}/features", height="700", alt="{Platform} Pivot Grid Basic Features Example"`
572572
573+
### Auto generate configuration
574+
The `autoGenerateConfig` property automatically generates dimensions and values based on the data source fields:
575+
576+
- Numeric Fields:
577+
- Created as `PivotValue` using `PivotNumericAggregate.sum` aggregator.
578+
- Added to the values collection and enabled by default.
579+
580+
- Non-Numeric Fields:
581+
- Created as `PivotDimension`.
582+
- Disabled by default.
583+
- Added to the columns collection.
584+
585+
- Date Fields(only the first `date` field is enabled, the other `date` fields apply non-numeric fields rule):
586+
- Created as `PivotDateDimension`
587+
- Enabled by default
588+
- added to the rows collection.
589+
590+
This feature allows developers to quickly create a pivot view without manually specifying dimensions and values. With a pivot selector next to the pivot grid, users can enable and reorder dimensions and values as needed.
591+
592+
### Pivot Value Calculation Keys
593+
594+
The Pivot grid provides a customization to the object keys fields it uses to do its pivot calculations.
595+
A more detailed view of how they are used can be seen bellow in example data, where you can see already aggregated values:
596+
```json
597+
[
598+
{
599+
ProductCategory: 'All', AllProducts: 'All Products', All: 1000, 'All-Bulgaria': 774, 'All-USA': 829, 'All-Uruguay': 524,
600+
AllProducts_records: [
601+
{ ProductCategory: 'Clothing', 'All-Bulgaria': 774, 'All-USA': 296, 'All-Uruguay': 456 },
602+
{ ProductCategory: 'Bikes', 'All-Uruguay': 68 },
603+
{ ProductCategory: 'Accessories', 'All-USA': 293 },
604+
{ ProductCategory: 'Components', 'All-USA': 240 }
605+
]
606+
}
607+
];
608+
```
609+
610+
All of these are stored in the **pivotKeys** property which is part of the `PivotConfiguration` and can be used to change the default pivot keys.
611+
- **children** - Field that stores children for hierarchy building. It represents a map from grouped values and all the pivotGridRecords that are based on that value. It can be utilized in very specific scenarios, where there is a need to do something while creating the hierarchies. No need to change this for common usage.
612+
- **records** - Field that stores reference to the original data records. Can be seen in the example from above - **AllProducts_records**. Avoid setting fields in the data with the same name as this property. If your data records has **records** property, you can specify different and unique value for it using the **pivotKeys**.
613+
- **aggregations** - Field that stores aggregation values. It's applied while creating the hierarchies and also it should not be changed for common scenarios.
614+
- **level** - Field that stores dimension level based on its hierarchy. Avoid setting fields in the data with the same name as this property. If your data records has **level** property, you can specify different and unique value for it using the **pivotKeys**.
615+
- **columnDimensionSeparator** - Separator used when generating the unique column field values. It is the dash(**-**) from example value - **All-Bulgaria**.
616+
- **rowDimensionSeparator** - Separator used when generating the unique row field values. It's used when creating the **records** and **level** field.
617+
618+
The default values are:
619+
```typescript
620+
{
621+
aggregations: 'aggregations',
622+
records: 'records',
623+
children: 'children',
624+
level: 'level',
625+
rowDimensionSeparator: '_',
626+
columnDimensionSeparator: '-'
627+
};
628+
```
629+
630+
```razor
631+
@code {
632+
{
633+
aggregations: 'aggregations',
634+
records: 'records',
635+
children: 'children',
636+
level: 'level',
637+
rowDimensionSeparator: '_',
638+
columnDimensionSeparator: '-'
639+
};
640+
}
641+
```
642+
643+
> [!Note]
644+
> If you have data field values that contain the default keys, make sure to change the separators that match to any other symbols that you are not currently using. Otherwise could lead to unexpected behavior in calculating and showing the aggregated values.
645+
646+
<!-- Blazor -->
647+
When overriding the `PivotKeys` in Blazor, currently you will need to define all other keys, since assigning a new PivotKeys object, it replaces completely the default ones:
648+
649+
```razor
650+
@code {
651+
var pivotConfiguration = new IgbPivotConfiguration();
652+
pivotConfiguration.PivotKeys = new IgbPivotKeys()
653+
{
654+
Aggregations = "aggregations",
655+
Records = "records",
656+
Children = "children",
657+
Level = "level",
658+
RowDimensionSeparator = "_",
659+
ColumnDimensionSeparator = "^"
660+
};
661+
}
662+
```
663+
<!-- end: Blazor -->
664+
573665
## Known Issues and Limitations
574666

575667
|Limitation|Description|

0 commit comments

Comments
 (0)