- @{
- var columnCount = AllowSelection ? columns.Count + 1 : columns.Count;
- }
- @if (EmptyDataTemplate == null)
+ @if (EmptyDataTemplate is null)
{
@@ -109,7 +118,7 @@
}
else if (totalCount > 0)
{
- if (items != null)
+ if (items is not null)
{
var rowIndex = 0;
foreach (var item in items)
diff --git a/blazorbootstrap/Components/Grid/Grid.razor.cs b/blazorbootstrap/Components/Grid/Grid.razor.cs
index fb51a9a1a..4ba7a6b04 100644
--- a/blazorbootstrap/Components/Grid/Grid.razor.cs
+++ b/blazorbootstrap/Components/Grid/Grid.razor.cs
@@ -144,6 +144,10 @@ internal async Task RefreshDataAsync(bool firstRender = false, CancellationToken
requestInProgress = true;
+ await InvokeAsync(StateHasChanged); // chnage the state to show the loading
+
+ await Task.Delay(300);
+
if (firstRender)
await LoadGridSettingsAsync();
@@ -696,6 +700,11 @@ private void SetFilters(IEnumerable filterItems)
//[EditorRequired]
public string ItemsPerPageText { get; set; } = "Items per page"!;
+ ///
+ /// Template to render when the grid is loading.
+ ///
+ public RenderFragment LoadingTemplate { get; set; } = default!;
+
///
/// This event is triggered when the user clicks on the row.
/// Set AllowRowClick to true to enable row clicking.
diff --git a/blazorbootstrap/Components/Grid/GridColumnFilter.razor b/blazorbootstrap/Components/Grid/GridColumnFilter.razor
index 153440c07..617cf385c 100644
--- a/blazorbootstrap/Components/Grid/GridColumnFilter.razor
+++ b/blazorbootstrap/Components/Grid/GridColumnFilter.razor
@@ -55,7 +55,7 @@
else if (PropertyTypeName == StringConstants.PropertyTypeNameEnum)
{
-
+
@if (string.IsNullOrWhiteSpace(filterValue))
{
Select
diff --git a/blazorbootstrap/Components/Grid/GridColumnFilter.razor.cs b/blazorbootstrap/Components/Grid/GridColumnFilter.razor.cs
index 78299665c..0b505d31f 100644
--- a/blazorbootstrap/Components/Grid/GridColumnFilter.razor.cs
+++ b/blazorbootstrap/Components/Grid/GridColumnFilter.razor.cs
@@ -160,7 +160,7 @@ or StringConstants.PropertyTypeNameDecimal
[Parameter]
public GridFiltersTranslationDelegate FiltersTranslationProvider { get; set; } = default!;
- private string filterStyle => FilterWidth > 0 ? $"width:{FilterWidth.ToString(CultureInfo.InvariantCulture)}{Unit};" : "";
+ private string filterStyle => FilterWidth > 0 ? $"width:{FilterWidth.ToString(CultureInfo.InvariantCulture)}{Unit.ToString().ToLower()};" : "";
///
/// Gets or sets filter value.
diff --git a/docs/docs/05-components/grid.mdx b/docs/docs/05-components/grid.mdx
index 1a4b956a1..1ff738f81 100644
--- a/docs/docs/05-components/grid.mdx
+++ b/docs/docs/05-components/grid.mdx
@@ -3134,3 +3134,172 @@ Automatically hides the paging controls when the grid item count is less than or
```
[See demo here](https://demos.blazorbootstrap.com/grid#auto-hide-paging)
+
+### Enum filter
+
+
+
+```cshtml {} showLineNumbers
+
+
+
+ @context.Id
+
+
+ @context.Name
+
+
+ @context.DOB
+
+
+ @context.Status
+
+
+
+```
+
+```cshtml {} showLineNumbers
+@code {
+ BlazorBootstrap.Grid grid = default!;
+ private IEnumerable users = default!;
+
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ await base.OnAfterRenderAsync(firstRender);
+ }
+
+ private async Task> UsersDataProvider(GridDataProviderRequest request)
+ {
+ if (users is null) // pull employees only one time for client-side filtering, sorting, and paging
+ users = GetUsers(); // call a service or an API to pull the employees
+
+ return await Task.FromResult(request.ApplyTo(users));
+ }
+
+ private IEnumerable GetUsers()
+ {
+ return new List
+ {
+ new User { Id = 107, Name = "Alice", DOB = new DateOnly(1998, 11, 17), Status = UserStatus.Registered },
+ new User { Id = null, Name = "Bob", DOB = new DateOnly(1985, 1, 5), Status = UserStatus.Verified },
+ new User { Id = 106, Name = "John", DOB = new DateOnly(1995, 4, 17), Status = UserStatus.Registered },
+ new User { Id = 104, Name = "Pop", DOB = new DateOnly(1985, 6, 8), Status = UserStatus.Registered },
+ new User { Id = 105, Name = "Ronald", DOB = new DateOnly(1991, 8, 23), Status = UserStatus.VerificationPending },
+ new User { Id = 102, Name = "Line", DOB = new DateOnly(1977, 1, 12), Status = UserStatus.VerificationPending },
+ new User { Id = 101, Name = "Daniel", DOB = new DateOnly(1977, 1, 12), Status = UserStatus.Registered },
+ new User { Id = 108, Name = "Zayne", DOB = new DateOnly(1991, 1, 1), Status = UserStatus.Verified },
+ new User { Id = 109, Name = "Isha", DOB = null, Status = UserStatus.Verified },
+ new User { Id = 110, Name = "Vijay", DOB = new DateOnly(1990, 7, 1), Status = UserStatus.Verified },
+ };
+ }
+
+ public record class User
+ {
+ public int? Id { get; set; }
+ public string? Name { get; set; }
+ public DateOnly? DOB { get; set; }
+ public UserStatus Status { get; set; }
+ }
+
+ public enum UserStatus
+ {
+ Registered,
+ VerificationPending,
+ Verified
+ }
+}
+```
+
+[See demo here](https://demos.blazorbootstrap.com/grid#enum-filter)
+
+### Guid filter
+
+
+
+```cshtml {
+
+
+
+ @context.Oid
+
+
+ @context.Id
+
+
+ @context.Name
+
+
+ @context.DOB
+
+
+ @context.Status
+
+
+
+} showLineNumbers
+```
+
+```cshtml {} showLineNumbers
+@code {
+ BlazorBootstrap.Grid grid = default!;
+ private IEnumerable users = default!;
+
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ await base.OnAfterRenderAsync(firstRender);
+ }
+
+ private async Task> UsersDataProvider(GridDataProviderRequest request)
+ {
+ if (users is null) // pull employees only one time for client-side filtering, sorting, and paging
+ users = GetUsers(); // call a service or an API to pull the employees
+
+ return await Task.FromResult(request.ApplyTo(users));
+ }
+
+ private IEnumerable GetUsers()
+ {
+ return new List
+ {
+ new User { Oid = Guid.NewGuid(), Id = 107, Name = "Alice", DOB = new DateOnly(1998, 11, 17), Status = UserStatus.Registered },
+ new User { Oid = Guid.NewGuid(), Id = null, Name = "Bob", DOB = new DateOnly(1985, 1, 5), Status = UserStatus.Verified },
+ new User { Oid = Guid.NewGuid(), Id = 106, Name = "John", DOB = new DateOnly(1995, 4, 17), Status = UserStatus.Registered },
+ new User { Oid = Guid.NewGuid(), Id = 104, Name = "Pop", DOB = new DateOnly(1985, 6, 8), Status = UserStatus.Registered },
+ new User { Oid = Guid.NewGuid(), Id = 105, Name = "Ronald", DOB = new DateOnly(1991, 8, 23), Status = UserStatus.VerificationPending },
+ new User { Oid = Guid.NewGuid(), Id = 102, Name = "Line", DOB = new DateOnly(1977, 1, 12), Status = UserStatus.VerificationPending },
+ new User { Oid = Guid.NewGuid(), Id = 101, Name = "Daniel", DOB = new DateOnly(1977, 1, 12), Status = UserStatus.Registered },
+ new User { Oid = Guid.NewGuid(), Id = 108, Name = "Zayne", DOB = new DateOnly(1991, 1, 1), Status = UserStatus.Verified },
+ new User { Oid = Guid.NewGuid(), Id = 109, Name = "Isha", DOB = null, Status = UserStatus.Verified },
+ new User { Oid = Guid.NewGuid(), Id = 110, Name = "Vijay", DOB = new DateOnly(1990, 7, 1), Status = UserStatus.Verified },
+ };
+ }
+
+ public record class User
+ {
+ public Guid Oid { get; set; }
+ public int? Id { get; set; }
+ public string? Name { get; set; }
+ public DateOnly? DOB { get; set; }
+ public UserStatus Status { get; set; }
+ }
+
+ public enum UserStatus
+ {
+ Registered,
+ VerificationPending,
+ Verified
+ }
+}
+```
+
+[See demo here](https://demos.blazorbootstrap.com/grid#guid-filter)
|