Skip to content

Commit

Permalink
add forceReload option
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Aug 19, 2024
1 parent e1e1146 commit bed9a20
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions samples/Sample.Core/Pages/DataGrid/Examples/Banks.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

<h3>Banks</h3>

<button class="btn btn-secondary" @onclick="@(() => DataGrid.RefreshAsync(forceReload: true))">Reload</button>

<DataGrid DataLoader="LoadData" class="table table-hover" @ref="DataGrid" RowAttributes="RowAttributes" Filterable="true" Groupable="true">
<DataColumns>
<DataColumn TItem="Bank" Property="p => p.BankName" Grouping="true" SortIndex="0" />
Expand Down
6 changes: 5 additions & 1 deletion src/LoreSoft.Blazor.Controls/Data/DataComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions src/LoreSoft.Blazor.Controls/Data/DataGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ public async Task ApplyFilters(IEnumerable<QueryRule> 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<TItem>());

await base.RefreshAsync(resetPager);
await base.RefreshAsync(resetPager, forceReload);
}


Expand Down

0 comments on commit bed9a20

Please sign in to comment.