+
@Title
- @if (Grid.ResizeType is not null && ColumnOptions is not null)
- {
- @if (Filtered.GetValueOrDefault())
- {
-
- }
- }
+ @if (ColumnOptions is not null && Filtered.GetValueOrDefault())
+ {
+
+ }
}
@if (Align == Align.End)
{
@if (Grid.ResizeType is not null)
{
-
Grid.ShowColumnOptionsAsync(this))" aria-label="Filter this column">
-
-
+ @OptionsButton()
}
else
{
@if (ColumnOptions is not null)
{
-
Grid.ShowColumnOptionsAsync(this))" aria-label="Filter this column">
- @if (Filtered.GetValueOrDefault())
- {
-
- }
- else
- {
-
- }
-
-
+ @FilterButton()
}
}
}
+
}
}
@@ -171,4 +151,28 @@
@PlaceholderTemplate(placeholderContext)
}
}
+
+ private RenderFragment OptionsButton()
+ {
+ return
+ @
Grid.ShowColumnOptionsAsync(this))" aria-label="Filter this column">
+
+ ;
+ }
+
+ private RenderFragment FilterButton()
+ {
+ return
+ @
Grid.ShowColumnOptionsAsync(this))" aria-label="Filter this column">
+ @if (Filtered.GetValueOrDefault())
+ {
+
+ }
+ else
+ {
+
+ }
+
+ ;
+ }
}
diff --git a/src/Core/Components/DataGrid/Columns/ColumnBase.razor.cs b/src/Core/Components/DataGrid/Columns/ColumnBase.razor.cs
index def61a9c7..d0a3a3299 100644
--- a/src/Core/Components/DataGrid/Columns/ColumnBase.razor.cs
+++ b/src/Core/Components/DataGrid/Columns/ColumnBase.razor.cs
@@ -14,7 +14,7 @@ public abstract partial class ColumnBase
{
private bool _isMenuOpen;
private static readonly string[] KEYBOARD_MENU_SELECT_KEYS = ["Enter", "NumpadEnter"];
- private readonly string _columnId = $"column-header{Identifier.NewId()}";
+ private readonly string _columnId = Identifier.NewId();
[CascadingParameter]
internal InternalGridContext InternalGridContext { get; set; } = default!;
@@ -26,6 +26,13 @@ public abstract partial class ColumnBase
[Parameter]
public string? Title { get; set; }
+
+ ///
+ /// Gets or sets the index (1-based) of the column
+ ///
+ [Parameter]
+ public int Index { get; set; }
+
///
/// Gets or sets the an optional CSS class name.
/// If specified, this is included in the class attribute of header and grid cells
@@ -140,6 +147,14 @@ public abstract partial class ColumnBase
protected bool AnyColumnActionEnabled => Sortable is true || IsDefaultSortColumn || ColumnOptions != null || Grid.ResizableColumns;
+ protected override void OnInitialized()
+ {
+ if (GetType() == typeof(SelectColumn))
+ {
+ Align = Align.Center;
+ }
+ }
+
///
/// Event callback for when the row is clicked.
///
@@ -221,7 +236,7 @@ protected void HandleKeyDown(FluentKeyCodeEventArgs e)
}
}
- public bool ShowSortIcon;
+ public bool IsActiveSortColumn;
///
/// Constructs an instance of .
@@ -252,7 +267,7 @@ private async Task HandleSortMenuKeyDownAsync(KeyboardEventArgs args)
if (KEYBOARD_MENU_SELECT_KEYS.Contains(args.Key))
{
await Grid.SortByColumnAsync(this);
- StateHasChanged();
+ StateHasChanged();
_isMenuOpen = false;
}
}
@@ -277,12 +292,12 @@ private async Task HandleOptionsMenuKeyDownAsync(KeyboardEventArgs args)
private string GetSortOptionText()
{
- if (Grid.SortByAscending.HasValue && ShowSortIcon)
+ if (Grid.SortByAscending.HasValue && IsActiveSortColumn)
{
if (Grid.SortByAscending is true)
{
return Grid.ColumnSortLabels.SortMenuAscendingLabel;
- }
+ }
else
{
return Grid.ColumnSortLabels.SortMenuDescendingLabel;
diff --git a/src/Core/Components/DataGrid/Columns/ColumnBase.razor.css b/src/Core/Components/DataGrid/Columns/ColumnBase.razor.css
index 632ba1fbd..cbf496e9c 100644
--- a/src/Core/Components/DataGrid/Columns/ColumnBase.razor.css
+++ b/src/Core/Components/DataGrid/Columns/ColumnBase.razor.css
@@ -1,30 +1,16 @@
-/* Contains the title text and sort indicator, and expands to fill as much of the col width as it can */
.col-title {
- display: flex; /* So that we can make col-title-text expand as much as possible, and still hide overflow with ellipsis */
- min-width: 0px;
- flex-grow: 1;
- padding: 0;
+ padding: 0.4rem 0.8rem;
+ user-select: none;
}
-/* If the column is sortable, its title is rendered as a button element for accessibility and to support navigation by tab */
-button.col-title {
- border: none;
- background: none;
- position: relative;
- cursor: pointer;
-}
-
-.col-justify-center .col-title {
- justify-content: center;
-}
-
-.col-justify-end .col-title, .col-justify-right .col-title {
- flex-direction: row-reverse; /* For end-justified cols, the sort indicator should appear before the title text */
-}
-
-/* We put the column title text in its own element primarily so that it can use text-overflow: ellipsis */
.col-title-text {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
+ font-weight: 600;
+}
+
+th.col-justify-center svg {
+ align-content: center;
+ text-align:center;
}
diff --git a/src/Core/Components/DataGrid/Columns/ColumnResizeOptions.razor b/src/Core/Components/DataGrid/Columns/ColumnResizeOptions.razor
index 23d1aed46..120a15234 100644
--- a/src/Core/Components/DataGrid/Columns/ColumnResizeOptions.razor
+++ b/src/Core/Components/DataGrid/Columns/ColumnResizeOptions.razor
@@ -24,6 +24,7 @@
ImmediateDelay="200"
Label="@Grid.ColumnResizeLabels.ExactLabel"
AutoComplete="off"
+ Autofocus="true"
@onkeydown="@HandleColumnWidthKeyDownAsync" />