From bed9a205d537de52167794f036353438fa31d3a2 Mon Sep 17 00:00:00 2001 From: Paul Welter Date: Sun, 18 Aug 2024 21:56:36 -0500 Subject: [PATCH] add forceReload option --- samples/Sample.Core/Pages/DataGrid/Examples/Banks.razor | 2 ++ src/LoreSoft.Blazor.Controls/Data/DataComponentBase.cs | 6 +++++- src/LoreSoft.Blazor.Controls/Data/DataGrid.razor.cs | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/samples/Sample.Core/Pages/DataGrid/Examples/Banks.razor b/samples/Sample.Core/Pages/DataGrid/Examples/Banks.razor index 2225174..cc3f92c 100644 --- a/samples/Sample.Core/Pages/DataGrid/Examples/Banks.razor +++ b/samples/Sample.Core/Pages/DataGrid/Examples/Banks.razor @@ -5,6 +5,8 @@

Banks

+ + diff --git a/src/LoreSoft.Blazor.Controls/Data/DataComponentBase.cs b/src/LoreSoft.Blazor.Controls/Data/DataComponentBase.cs index 3e2452c..8692043 100644 --- a/src/LoreSoft.Blazor.Controls/Data/DataComponentBase.cs +++ b/src/LoreSoft.Blazor.Controls/Data/DataComponentBase.cs @@ -67,12 +67,16 @@ public bool IsLoading protected Exception DataError { get; private set; } - public virtual async Task RefreshAsync(bool resetPager = false) + public virtual async Task RefreshAsync(bool resetPager = false, bool forceReload = false) { // reset page if (resetPager) Pager.Reset(); + // clear cached data to force data loader to re-run + if (forceReload && DataLoader != null) + _data = null; + await RefreshCoreAsync(); } diff --git a/src/LoreSoft.Blazor.Controls/Data/DataGrid.razor.cs b/src/LoreSoft.Blazor.Controls/Data/DataGrid.razor.cs index 1d86de3..3bfb5c5 100644 --- a/src/LoreSoft.Blazor.Controls/Data/DataGrid.razor.cs +++ b/src/LoreSoft.Blazor.Controls/Data/DataGrid.razor.cs @@ -138,13 +138,13 @@ public async Task ApplyFilters(IEnumerable rules, bool replace = fals } - public override async Task RefreshAsync(bool resetPager = false) + public override async Task RefreshAsync(bool resetPager = false, bool forceReload = false) { // clear row flags on refresh _expandedItems.Clear(); SetSelectedItems(new List()); - await base.RefreshAsync(resetPager); + await base.RefreshAsync(resetPager, forceReload); }