diff --git a/src/.vuepress/public/.attachments/applications/Controls/VirtualDataset/aggregations.png b/src/.vuepress/public/.attachments/applications/Controls/VirtualDataset/aggregations.png new file mode 100644 index 000000000..937454dc6 Binary files /dev/null and b/src/.vuepress/public/.attachments/applications/Controls/VirtualDataset/aggregations.png differ diff --git a/src/en/developer-guide/applications/controls/VirtualDataset/ClientExtensibility/general.md b/src/en/developer-guide/applications/controls/VirtualDataset/ClientExtensibility/general.md index c83ed9b71..876eab338 100644 --- a/src/en/developer-guide/applications/controls/VirtualDataset/ClientExtensibility/general.md +++ b/src/en/developer-guide/applications/controls/VirtualDataset/ClientExtensibility/general.md @@ -32,6 +32,18 @@ function onFormLoad(executionContext) { > **_NOTE:_** If you are using Typescript, you should always use Dataset typings (`IDataset`, `IRecord`...) from `@talxis/client-libraries`. **DO NOT USE** any properties/methods that are not defined in typings. If you do, your scripts might break with any PCF update! +## Aggregations +If the control has active aggregations, it automatically creates a virtual record that contains the aggregated values and pinnes it to the bottom of the dataset. This record is not part of the regular dataset, so you cannot acces it through the `onRecordLoaded` event. In order to access this record instance, you need to retrieve the dataset that was used to create this record. This can be done by registering the `onChildDatasetInitialized` event on the main dataset. Once you have the aggregated dataset instance, you can register events and expressions the same as you would for the main dataset. + +```javascript +dataset.addEventListener('onChildDatasetInitialized', (childDataset) => { + childDataset.addEventListener('onRecordLoaded', (record) => { + //register record expressions for the aggregated record + }) +}) +``` +> **_NOTE:_** Due to issues with compatibility, validations are completely disabled for the aggregated record. All other client extensibility features are available, including custom controls, notifications, and conditional formatting. + ## Interceptors Interceptors are a way to intercept certain flows in Dataset and inject your own data. diff --git a/src/en/developer-guide/applications/controls/VirtualDataset/general.md b/src/en/developer-guide/applications/controls/VirtualDataset/general.md index 501a41a4b..00ef3164e 100644 --- a/src/en/developer-guide/applications/controls/VirtualDataset/general.md +++ b/src/en/developer-guide/applications/controls/VirtualDataset/general.md @@ -7,6 +7,7 @@ Virtual Dataset allows you to bind a Dataset Base Control to a field while provi - **Sorting** - **Filtering** +- **Aggregations** - **Paging** - **Validation** - **Editing (including linked entities)** @@ -314,6 +315,7 @@ In order to provide more features, we have [extended]() the native column interf | `metadata` | Allows you to define or override [Xrm Attribute Metadata](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/reference/attributemetadata?view=dataverse-latest) for a column. | | `oneClickEdit`| Removes the need to double-click a cell to edit its value. Note: Enabling this on too many columns may reduce performance; use only when the performance decrease is acceptable for your use case. | | `controls ` | Used to set up [cell customizers](). +| `aggregationFunction` | Name of the aggregation function to apply to the column. This aggregation will be automatically applied to the control. | ### Provider specific features @@ -353,6 +355,34 @@ There are multiple ways to set the height of the control. By default, the contro  *Control with Expand to full tab feature on.* +## Column Aggregations + +It is possible to set aggregations on columns via the `aggregationFunction` property in the column definition. Depending on the column type and provider, the following aggregation functions are available: + +`countcolumn`, `count`, `min`, `max`, `sum`, `avg` + +Each provider populates the `SupportedAggregations` array in column metadata to indicate which aggregations a specific column supports. Users can configure aggregations via the UI when the `EnableAggregation` binding is set to `true`. To limit the aggregations available in the UI, set the `SupportedAggregations` property in the column bindings. + +```json +{ + "name": "amount", + "alias": "amount", + "dataType": "Whole.None", + "displayName": "Amount", + "order": 0, + "visualSizeFactor": 150, + "metadata": { + "SupportedAggregations": ["sum", "avg"] + } +} +``` +*Restricting aggregations for `Amount` column to sum and average.* + + +*Control with aggregations set on `Decimal` and `Whole.None` columns.* + + + ## Bindings Summary @@ -522,6 +552,15 @@ There are multiple ways to set the height of the control. By default, the contro
inputfalseEnum ("Yes" | "No")"Yes"N/Ainputfalse