fix(client): use grid reference pattern for explicit refresh after data changes
Fixes Clear Data bug in filter panels by using Radzen-recommended @ref + Reload() pattern instead of relying on implicit data binding to update the grid display.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Radzen;
|
||||
using Radzen.Blazor;
|
||||
|
||||
namespace JdeScoping.Client.Components.FilterPanels;
|
||||
|
||||
@@ -48,6 +49,11 @@ public abstract class AutocompleteFilterPanelBase<TItem> : ComponentBase where T
|
||||
/// </summary>
|
||||
protected TItem? SelectedItem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the data grid for explicit refresh.
|
||||
/// </summary>
|
||||
protected RadzenDataGrid<TItem>? Grid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title displayed in the panel header.
|
||||
/// </summary>
|
||||
@@ -156,6 +162,7 @@ public abstract class AutocompleteFilterPanelBase<TItem> : ComponentBase where T
|
||||
{
|
||||
Items.Remove(item);
|
||||
await ItemsChanged.InvokeAsync(Items);
|
||||
if (Grid != null) await Grid.Reload();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -168,6 +175,7 @@ public abstract class AutocompleteFilterPanelBase<TItem> : ComponentBase where T
|
||||
{
|
||||
Items.Clear();
|
||||
await ItemsChanged.InvokeAsync(Items);
|
||||
if (Grid != null) await Grid.Reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
</RadzenStack>
|
||||
|
||||
<RadzenDataGrid Data="@Items" TItem="ComponentLotViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<RadzenDataGrid @ref="Grid" Data="@Items" TItem="ComponentLotViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<Columns>
|
||||
<RadzenDataGridColumn TItem="ComponentLotViewModel" Property="LotNumber" Title="Lot Number" />
|
||||
<RadzenDataGridColumn TItem="ComponentLotViewModel" Property="ItemNumber" Title="Item Number" />
|
||||
|
||||
@@ -46,6 +46,11 @@ public abstract class FileUploadFilterPanelBase<TItem> : ComponentBase where TIt
|
||||
/// </summary>
|
||||
protected bool IsUploading { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the data grid for explicit refresh.
|
||||
/// </summary>
|
||||
protected RadzenDataGrid<TItem>? Grid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title displayed in the panel header.
|
||||
/// </summary>
|
||||
@@ -138,6 +143,7 @@ public abstract class FileUploadFilterPanelBase<TItem> : ComponentBase where TIt
|
||||
{
|
||||
Items.Clear();
|
||||
await ItemsChanged.InvokeAsync(Items);
|
||||
if (Grid != null) await Grid.Reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</RadzenRow>
|
||||
}
|
||||
|
||||
<RadzenDataGrid Data="@Items" TItem="ItemViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<RadzenDataGrid @ref="_grid" Data="@Items" TItem="ItemViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<Columns>
|
||||
<RadzenDataGridColumn TItem="ItemViewModel" Property="ItemNumber" Title="Item Number" Width="150px" />
|
||||
<RadzenDataGridColumn TItem="ItemViewModel" Property="Description" Title="Description" />
|
||||
@@ -76,6 +76,7 @@
|
||||
private List<ItemViewModel> _searchResults = [];
|
||||
private ItemViewModel? _selectedItem;
|
||||
private bool _isUploading;
|
||||
private RadzenDataGrid<ItemViewModel>? _grid;
|
||||
|
||||
private async Task OnSearchAsync(LoadDataArgs args)
|
||||
{
|
||||
@@ -124,6 +125,7 @@
|
||||
{
|
||||
Items.Remove(item);
|
||||
await ItemsChanged.InvokeAsync(Items);
|
||||
if (_grid != null) await _grid.Reload();
|
||||
}
|
||||
|
||||
private async Task DownloadTemplateAsync()
|
||||
@@ -207,6 +209,7 @@
|
||||
{
|
||||
Items.Clear();
|
||||
await ItemsChanged.InvokeAsync(Items);
|
||||
if (_grid != null) await _grid.Reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</RadzenRow>
|
||||
}
|
||||
|
||||
<RadzenDataGrid Data="@Items" TItem="OperatorViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<RadzenDataGrid @ref="Grid" Data="@Items" TItem="OperatorViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<Columns>
|
||||
<RadzenDataGridColumn TItem="OperatorViewModel" Property="AddressNumber" Title="Address Number" Width="150px" />
|
||||
<RadzenDataGridColumn TItem="OperatorViewModel" Property="UserID" Title="User Name" Width="150px" />
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
}
|
||||
</RadzenStack>
|
||||
|
||||
<RadzenDataGrid Data="@Items" TItem="PartOperationViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<RadzenDataGrid @ref="Grid" Data="@Items" TItem="PartOperationViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<Columns>
|
||||
<RadzenDataGridColumn TItem="PartOperationViewModel" Property="ItemNumber" Title="Item Number" />
|
||||
<RadzenDataGridColumn TItem="PartOperationViewModel" Property="OperationNumber" Title="Operation Step Number" />
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</RadzenRow>
|
||||
}
|
||||
|
||||
<RadzenDataGrid Data="@Items" TItem="ProfitCenterViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<RadzenDataGrid @ref="Grid" Data="@Items" TItem="ProfitCenterViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<Columns>
|
||||
<RadzenDataGridColumn TItem="ProfitCenterViewModel" Property="Code" Title="Profit Center" Width="150px" />
|
||||
<RadzenDataGridColumn TItem="ProfitCenterViewModel" Property="Description" Title="Description" />
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</RadzenRow>
|
||||
}
|
||||
|
||||
<RadzenDataGrid Data="@Items" TItem="WorkCenterViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<RadzenDataGrid @ref="Grid" Data="@Items" TItem="WorkCenterViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<Columns>
|
||||
<RadzenDataGridColumn TItem="WorkCenterViewModel" Property="Code" Title="Work Center" Width="150px" />
|
||||
<RadzenDataGridColumn TItem="WorkCenterViewModel" Property="Description" Title="Description" />
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
}
|
||||
</RadzenStack>
|
||||
|
||||
<RadzenDataGrid Data="@Items" TItem="WorkOrderViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<RadzenDataGrid @ref="Grid" Data="@Items" TItem="WorkOrderViewModel" AllowSorting="true" Style="min-height: 150px; max-height: 300px;">
|
||||
<Columns>
|
||||
<RadzenDataGridColumn TItem="WorkOrderViewModel" Property="WorkOrderNumber" Title="Work Order Number" />
|
||||
<RadzenDataGridColumn TItem="WorkOrderViewModel" Property="ItemNumber" Title="Item Number" />
|
||||
|
||||
Reference in New Issue
Block a user