From c93518202baf019cb7b215600d1096c5ef11df56 Mon Sep 17 00:00:00 2001 From: OlgunR Date: Fri, 17 Apr 2026 12:08:39 +0200 Subject: [PATCH] Add custom toolbar actions with icons to grids Introduce Add, Edit, and Delete buttons with Bootstrap Icons in the toolbars of CatalogsGrid and MassDataGrid. Hide the default command column by overriding ShowCommandColumn. Update BandGridBase to conditionally render the command column. Track focused row index for toolbar actions, enabling row operations via toolbar instead of the grid's built-in command column. Add Bootstrap Icons stylesheet to App.razor. --- DbFirst.BlazorWebApp/Components/App.razor | 1 + .../Components/BandGridBase.cs | 13 ++++--- .../Components/CatalogsGrid.razor | 37 +++++++++++++++++++ .../Components/MassDataGrid.razor | 37 +++++++++++++++++++ 4 files changed, 83 insertions(+), 5 deletions(-) diff --git a/DbFirst.BlazorWebApp/Components/App.razor b/DbFirst.BlazorWebApp/Components/App.razor index 98a93a3..f6e8697 100644 --- a/DbFirst.BlazorWebApp/Components/App.razor +++ b/DbFirst.BlazorWebApp/Components/App.razor @@ -18,6 +18,7 @@ + diff --git a/DbFirst.BlazorWebApp/Components/BandGridBase.cs b/DbFirst.BlazorWebApp/Components/BandGridBase.cs index 29bbec7..47766cd 100644 --- a/DbFirst.BlazorWebApp/Components/BandGridBase.cs +++ b/DbFirst.BlazorWebApp/Components/BandGridBase.cs @@ -103,6 +103,8 @@ public abstract class BandGridBase : ComponentBase // --- Band-Methoden --- protected bool CanSaveBandLayout => !string.IsNullOrWhiteSpace(layoutUser); + protected virtual bool ShowCommandColumn => true; + protected void AddBand() { bandLayout.Bands.Add(new BandDefinition { Id = Guid.NewGuid().ToString("N"), Caption = "Band" }); @@ -172,9 +174,12 @@ public abstract class BandGridBase : ComponentBase protected RenderFragment RenderColumns() => builder => { var seq = 0; - builder.OpenComponent(seq++); - builder.AddAttribute(seq++, "Width", "120px"); - builder.CloseComponent(); + if (ShowCommandColumn) + { + builder.OpenComponent(seq++); + builder.AddAttribute(seq++, "Width", "120px"); + builder.CloseComponent(); + } var grouped = bandLayout.Bands.SelectMany(b => b.Columns).ToHashSet(StringComparer.OrdinalIgnoreCase); foreach (var column in ColumnDefinitions.Where(c => !grouped.Contains(c.FieldName))) @@ -184,8 +189,6 @@ public abstract class BandGridBase : ComponentBase { if (band.Columns.Count == 0) continue; builder.OpenComponent(seq++); - builder.AddAttribute(seq++, "Width", "120px"); - builder.AddAttribute(seq++, "NewButtonVisible", false); // falls noch nicht vorhanden builder.AddAttribute(seq++, "Caption", band.Caption); builder.AddAttribute(seq++, "Columns", (RenderFragment)(bandBuilder => { diff --git a/DbFirst.BlazorWebApp/Components/CatalogsGrid.razor b/DbFirst.BlazorWebApp/Components/CatalogsGrid.razor index 4647b7f..ca33b29 100644 --- a/DbFirst.BlazorWebApp/Components/CatalogsGrid.razor +++ b/DbFirst.BlazorWebApp/Components/CatalogsGrid.razor @@ -59,9 +59,34 @@ else DataItemDeleting="OnDataItemDeleting" FocusedRowEnabled="true" @bind-FocusedRowKey="focusedRowKey" + RowClick="@(args => _focusedVisibleIndex = args.VisibleIndex)" @ref="gridRef"> + + + + + + + + +