Skip to content

Commit 69955a2

Browse files
committed
Add filter warning indicator to DataGrid toolbar
1 parent 8dcffee commit 69955a2

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/LoreSoft.Blazor.Controls/Data/DataGridToolbar.razor

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
<h5 class="toolbar-title-text">@Title</h5>
1616
}
1717
</div>
18+
@if (ShowFilterWarning && CurrentGrid.IsFilterActive())
19+
{
20+
<div class="toolbar-filter-warning" title="Results are filtered. Click the filter icon to clear.">
21+
@FilterWarning
22+
</div>
23+
}
1824
@if (ShowSearch)
1925
{
2026
<div class="toolbar-search-box">

src/LoreSoft.Blazor.Controls/Data/DataGridToolbar.razor.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ public DataGridToolbar()
142142
[Parameter]
143143
public bool ShowColumnPicker { get; set; } = true;
144144

145+
/// <summary>
146+
/// Gets or sets a value indicating whether the filter warning indicator is displayed in the toolbar.
147+
/// When true, the <see cref="FilterWarning"/> content is shown whenever the DataGrid has an active filter applied.
148+
/// </summary>
149+
[Parameter]
150+
public bool ShowFilterWarning { get; set; } = true;
151+
152+
/// <summary>
153+
/// Gets or sets the content rendered as the active-filter warning indicator.
154+
/// Displayed when <see cref="ShowFilterWarning"/> is <c>true</c> and the DataGrid has an active filter.
155+
/// Defaults to a <c>"* Filter Applied *"</c> text node.
156+
/// </summary>
157+
[Parameter]
158+
public RenderFragment? FilterWarning { get; set; } = builder => builder.AddContent(0, "* Filter Applied *");
159+
145160
/// <summary>
146161
/// Gets the current <see cref="DataGrid{TItem}"/> instance in use by the toolbar.
147162
/// This property is derived from either the <see cref="DataGrid"/> parameter or the

src/LoreSoft.Blazor.Controls/wwwroot/css/data-toolbar.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131
white-space: nowrap;
3232
}
3333

34+
.data-toolbar .toolbar-filter-warning {
35+
font-size: .80rem;
36+
font-style: italic;
37+
margin: .5rem;
38+
opacity: .75;
39+
}
40+
3441
.data-toolbar select,
3542
.data-toolbar button,
3643
.data-toolbar input,
@@ -125,6 +132,7 @@
125132
.data-toolbar .toolbar-search-box {
126133
width: 100%;
127134
}
135+
128136
.data-toolbar .toolbar-control {
129137
width: 100%;
130138
}

0 commit comments

Comments
 (0)