Skip to content

Commit 73198f9

Browse files
authored
Merge pull request #6587 from syncfusion-content/EJ2-979359-Hotfix
979359: Move the "Dynamically Update Report Configuration" topic to the data-binding section
2 parents 908bfdc + 2b1b222 commit 73198f9

File tree

2 files changed

+90
-100
lines changed

2 files changed

+90
-100
lines changed

blazor/pivot-table/data-binding.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,96 @@ User can show custom string in empty value cells using the [EmptyCellsTextConten
11631163

11641164
![Empty Values in Blazor PivotTable](images/blazor-pivottable-empty-values.png)
11651165

1166+
## Dynamically update the report configuration
1167+
1168+
The Blazor Pivot Table component supports dynamic data source handling and report manipulation through the [`RefreshAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PivotView.SfPivotView-1.html#Syncfusion_Blazor_PivotView_SfPivotView_1_RefreshAsync_System_Boolean_) method. This method provides a streamlined and efficient approach to either refresh the component's layout or refresh the entire component, which re-initiates the engine process based on new data or report settings.
1169+
1170+
The [`RefreshAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PivotView.SfPivotView-1.html#Syncfusion_Blazor_PivotView_SfPivotView_1_RefreshAsync_System_Boolean_) method enables dynamic and asynchronous refreshing of the Pivot Table layout. It simplifies the update process and enhances responsiveness during runtime changes to report configurations.
1171+
1172+
This method accepts a boolean parameter, **allowDataRefresh**, which determines whether the underlying data source should be reprocessed:
1173+
1174+
* **`false`**: Refreshes only the component's layout based on the current report settings without reprocessing the entire data source.
1175+
* **`true`**: Performs a complete data refresh, which includes reprocessing the data source and recalculating all aggregations.
1176+
1177+
> By default, the parameter is `false`, which refreshes only the component's layout without reprocessing the underlying data.
1178+
1179+
In the following example, `true` is passed to the [`RefreshAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PivotView.SfPivotView-1.html#Syncfusion_Blazor_PivotView_SfPivotView_1_RefreshAsync_System_Boolean_) method to trigger a full data refresh, updating the Pivot Table with a new row and column added to the report at runtime.
1180+
1181+
```cshtml
1182+
@using Syncfusion.Blazor.PivotView
1183+
@using Syncfusion.Blazor.Buttons
1184+
1185+
<SfButton OnClick="UpdatePivotReport" Content="Update Pivot Report"></SfButton>
1186+
1187+
<SfPivotView TValue="ProductDetails" @ref="@pivot" Width="1200" Height="400" ShowGroupingBar="true" ShowFieldList="true">
1188+
<PivotViewDataSourceSettings DataSource="@data" ExpandAll="true">
1189+
<PivotViewColumns>
1190+
<PivotViewColumn Name="Year"></PivotViewColumn>
1191+
</PivotViewColumns>
1192+
<PivotViewRows>
1193+
<PivotViewRow Name="Country"></PivotViewRow>
1194+
</PivotViewRows>
1195+
<PivotViewValues>
1196+
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
1197+
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
1198+
</PivotViewValues>
1199+
<PivotViewFormatSettings>
1200+
<PivotViewFormatSetting Name="Amount" Format="C"></PivotViewFormatSetting>
1201+
</PivotViewFormatSettings>
1202+
</PivotViewDataSourceSettings>
1203+
</SfPivotView>
1204+
1205+
@code {
1206+
private SfPivotView<ProductDetails> pivot = null!;
1207+
public List<ProductDetails> data { get; set; } = null!;
1208+
1209+
protected override void OnInitialized()
1210+
{
1211+
this.data = ProductDetails.GetProductData();
1212+
}
1213+
1214+
public async Task UpdatePivotReport()
1215+
{
1216+
// Adding a new row to the report
1217+
pivot.DataSourceSettings.Rows.Add(new PivotViewRow
1218+
{
1219+
Name = "Products"
1220+
});
1221+
// Adding a new column to the report
1222+
pivot.DataSourceSettings.Columns.Add(new PivotViewColumn
1223+
{
1224+
Name = "Quarter",
1225+
Caption = "Quarter Name"
1226+
});
1227+
// Refresh the Pivot Table to reflect the changes
1228+
await pivot.RefreshAsync(true);
1229+
}
1230+
1231+
public class ProductDetails
1232+
{
1233+
public int Sold { get; set; }
1234+
public double Amount { get; set; }
1235+
public string? Country { get; set; }
1236+
public string? Products { get; set; }
1237+
public string? Year { get; set; }
1238+
public string? Quarter { get; set; }
1239+
1240+
public static List<ProductDetails> GetProductData()
1241+
{
1242+
List<ProductDetails> productDetails = new List<ProductDetails>()
1243+
{
1244+
new ProductDetails { Country = "Canada", Products = "Bike", Year = "FY 2022", Quarter = "Q1", Sold = 35, Amount = 52500 },
1245+
new ProductDetails { Country = "Canada", Products = "Car", Year = "FY 2022", Quarter = "Q2", Sold = 25, Amount = 62500 },
1246+
new ProductDetails { Country = "Germany", Products = "Bike", Year = "FY 2023", Quarter = "Q3", Sold = 40, Amount = 60000 },
1247+
new ProductDetails { Country = "Germany", Products = "Car", Year = "FY 2023", Quarter = "Q4", Sold = 30, Amount = 75000 },
1248+
new ProductDetails { Country = "United States", Products = "Bike", Year = "FY 2022", Quarter = "Q1", Sold = 50, Amount = 75000 },
1249+
};
1250+
return productDetails;
1251+
}
1252+
}
1253+
}
1254+
```
1255+
11661256
## Event
11671257

11681258
The event [OnLoad](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PivotView.PivotViewEvents-1.html#Syncfusion_Blazor_PivotView_PivotViewEvents_1_OnLoad) fires before initiate rendering of pivot table. It holds following parameters like [DataSourceSettings](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PivotView.LoadEventArgs-1.html#Syncfusion_Blazor_PivotView_LoadEventArgs_1_DataSourceSettings), [FieldsType](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PivotView.LoadEventArgs-1.html#Syncfusion_Blazor_PivotView_LoadEventArgs_1_FieldsType) and [PivotView](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PivotView.LoadEventArgs-1.html#Syncfusion_Blazor_PivotView_LoadEventArgs_1__ctor). In this event user can customize data source settings before initiating pivot table render module.

blazor/pivot-table/how-to/dynamically-update-pivot-table-report.md

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)