From 143c7e1023453c4dab13c54e2bf990482ebbed8a Mon Sep 17 00:00:00 2001 From: Dimo Dimov <961014+dimodi@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:38:57 +0300 Subject: [PATCH] docs(pivotgrid): Mention Rebind() in local data binding documentation --- components/pivotgrid/data-binding.md | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/components/pivotgrid/data-binding.md b/components/pivotgrid/data-binding.md index 87c0380940..39e3d7d168 100644 --- a/components/pivotgrid/data-binding.md +++ b/components/pivotgrid/data-binding.md @@ -25,11 +25,14 @@ The PivotGrid supports different data sources via its `DataProviderType` paramet When bound to local data, the Pivot Grid requires its `Data` parameter to provide all the data at once as `IEnumerable`. The component will perform all aggregate calculations in-memory and there is no [load on demand]({%slug pivotgrid-overview%}#pivotgrid-parameters). +If the local data changes programmatically, you need to reset the collection instance or [call the PivotGrid `Rebind()` method]({%slug pivotgrid-overview%}#pivotgrid-reference-and-methods). See the common documentation about [refreshing component data]({%slug common-features-data-binding-overview%}#refresh-data) for details. + > Large amounts of local data may impact the performance, especially in WebAssembly applications. >caption PivotGrid bound to Local data provider
+ ````CSHTML @@ -45,31 +48,34 @@ When bound to local data, the Pivot Grid requires its `Data` parameter to provid @code { - private List PivotData { get; set; } = new List(); + private List? PivotData { get; set; } - protected override void OnInitialized() + protected override async Task OnInitializedAsync() { var dataItemCount = 100; var categoryCount = 3; - var productCount = 5 + 1; // effectively 5, as rnd.Next() will never return 6 + var productCount = 5 + 1; // effectively 5, as Random.Shared.Next() will never return 6 var cityCount = 3 + 1; // effectively 3 - var rnd = new Random(); + + await Task.Delay(1000); // simulate network delay + + PivotData = new List(); // reset PivotData object reference if it exists for (int i = 1; i <= dataItemCount; i++) { - var productNumber = rnd.Next(1, productCount); + var productNumber = Random.Shared.Next(1, productCount); PivotData.Add(new PivotModel() { Category = $"Category {productNumber % categoryCount + 1}", Product = $"Product {productNumber}", - City = $"City {rnd.Next(1, cityCount)}", - ContractDate = DateTime.Now.AddDays(-rnd.Next(1, 31)).AddMonths(-rnd.Next(1, 12)).AddYears(-rnd.Next(0, 5)), - ContractValue = rnd.Next(123, 987) + City = $"City {Random.Shared.Next(1, cityCount)}", + ContractDate = DateTime.Now.AddDays(-Random.Shared.Next(1, 31)).AddMonths(-Random.Shared.Next(1, 12)).AddYears(-Random.Shared.Next(0, 5)), + ContractValue = Random.Shared.Next(123, 987) }); } - base.OnInitialized(); + await base.OnInitializedAsync(); } public class PivotModel