Skip to content

Commit 143c7e1

Browse files
dimodidimodi
authored andcommitted
docs(pivotgrid): Mention Rebind() in local data binding documentation
1 parent 3e7bdf3 commit 143c7e1

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

components/pivotgrid/data-binding.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ The PivotGrid supports different data sources via its `DataProviderType` paramet
2525

2626
When bound to local data, the Pivot Grid requires its `Data` parameter to provide all the data at once as `IEnumerable<TItem>`. The component will perform all aggregate calculations in-memory and there is no [load on demand]({%slug pivotgrid-overview%}#pivotgrid-parameters).
2727

28+
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.
29+
2830
> Large amounts of local data may impact the performance, especially in WebAssembly applications.
2931
3032
>caption PivotGrid bound to Local data provider
3133
3234
<div class="skip-repl"></div>
35+
3336
````CSHTML
3437
<TelerikPivotGrid Data="@PivotData">
3538
<PivotGridColumns>
@@ -45,31 +48,34 @@ When bound to local data, the Pivot Grid requires its `Data` parameter to provid
4548
</TelerikPivotGrid>
4649
4750
@code {
48-
private List<PivotModel> PivotData { get; set; } = new List<PivotModel>();
51+
private List<PivotModel>? PivotData { get; set; }
4952
50-
protected override void OnInitialized()
53+
protected override async Task OnInitializedAsync()
5154
{
5255
var dataItemCount = 100;
5356
var categoryCount = 3;
54-
var productCount = 5 + 1; // effectively 5, as rnd.Next() will never return 6
57+
var productCount = 5 + 1; // effectively 5, as Random.Shared.Next() will never return 6
5558
var cityCount = 3 + 1; // effectively 3
56-
var rnd = new Random();
59+
60+
await Task.Delay(1000); // simulate network delay
61+
62+
PivotData = new List<PivotModel>(); // reset PivotData object reference if it exists
5763
5864
for (int i = 1; i <= dataItemCount; i++)
5965
{
60-
var productNumber = rnd.Next(1, productCount);
66+
var productNumber = Random.Shared.Next(1, productCount);
6167
6268
PivotData.Add(new PivotModel()
6369
{
6470
Category = $"Category {productNumber % categoryCount + 1}",
6571
Product = $"Product {productNumber}",
66-
City = $"City {rnd.Next(1, cityCount)}",
67-
ContractDate = DateTime.Now.AddDays(-rnd.Next(1, 31)).AddMonths(-rnd.Next(1, 12)).AddYears(-rnd.Next(0, 5)),
68-
ContractValue = rnd.Next(123, 987)
72+
City = $"City {Random.Shared.Next(1, cityCount)}",
73+
ContractDate = DateTime.Now.AddDays(-Random.Shared.Next(1, 31)).AddMonths(-Random.Shared.Next(1, 12)).AddYears(-Random.Shared.Next(0, 5)),
74+
ContractValue = Random.Shared.Next(123, 987)
6975
});
7076
}
7177
72-
base.OnInitialized();
78+
await base.OnInitializedAsync();
7379
}
7480
7581
public class PivotModel

0 commit comments

Comments
 (0)