Skip to content

Commit e7a6d69

Browse files
authored
Grid Filter Button CSS #688 (#730)
1 parent 33ba26e commit e7a6d69

File tree

5 files changed

+45
-3
lines changed

5 files changed

+45
-3
lines changed

blazorbootstrap/Components/Grid/Grid.razor

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@
5050
<th class="@string.Join(" ", columnClassList)" style="@string.Join(";", columnStyleList)">
5151
@if (column.Filterable)
5252
{
53-
<GridColumnFilter FilterOperator="@column.FilterOperator"
53+
<GridColumnFilter FilterButtonColor="@column.FilterButtonColor"
54+
FilterButtonCSSClass="@column.FilterButtonCSSClass"
55+
FilterOperator="@column.FilterOperator"
5456
FilterValue="@column.FilterValue"
5557
FilterWidth="@column.FilterTextboxWidth"
56-
FiltersTranslationProvider="GridFiltersTranslationProviderAsync"
58+
FiltersTranslationProvider="GridFiltersTranslationProviderAsync!"
5759
FixedHeader="@FixedHeader"
5860
GridColumnFilterChanged="async args => await column.OnFilterChangedAsync(args, column)"
5961
PropertyType="@column.GetPropertyType()"

blazorbootstrap/Components/Grid/GridColumn.razor.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,24 @@ private async Task OnSortClickAsync()
212212
[Parameter]
213213
public bool Filterable { get; set; } = true;
214214

215+
/// <summary>
216+
/// Gets or sets the filter button color.
217+
/// </summary>
218+
/// <remarks>
219+
/// Default value is <see cref="ButtonColor.Light" />.
220+
/// </remarks>
221+
[Parameter]
222+
public ButtonColor FilterButtonColor { get; set; } = ButtonColor.Light;
223+
224+
/// <summary>
225+
/// Gets or sets the filter button CSS class.
226+
/// </summary>
227+
/// <remarks>
228+
/// Default value is null.
229+
/// </remarks>
230+
[Parameter]
231+
public string? FilterButtonCSSClass { get; set; }
232+
215233
/// <summary>
216234
/// Gets or sets the filter operator.
217235
/// </summary>

blazorbootstrap/Components/Grid/GridColumnFilter.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@inherits BlazorBootstrapComponentBase
33

44
<div class="d-flex">
5-
<button type="button" class="btn btn-light me-1 d-flex dropdown-toggle bb-grid-filter" data-bs-toggle="dropdown" aria-expanded="false">
5+
<button type="button" class="btn @filterButtonColorString me-1 d-flex dropdown-toggle bb-grid-filter @FilterButtonCSSClass" data-bs-toggle="dropdown" aria-expanded="false">
66
@if (string.IsNullOrWhiteSpace(filterValue))
77
{
88
<span class="me-2">

blazorbootstrap/Components/Grid/GridColumnFilter.razor.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,26 @@ or StringConstants.PropertyTypeNameDecimal
147147

148148
#region Properties, Indexers
149149

150+
/// <summary>
151+
/// Gets or sets the filter button color.
152+
/// </summary>
153+
/// <remarks>
154+
/// Default value is <see cref="ButtonColor.Light" />.
155+
/// </remarks>
156+
[Parameter]
157+
public ButtonColor FilterButtonColor { get; set; } = ButtonColor.Light;
158+
159+
/// <summary>
160+
/// Gets or sets the filter button CSS class.
161+
/// </summary>
162+
/// <remarks>
163+
/// Default value is null.
164+
/// </remarks>
165+
[Parameter]
166+
public string? FilterButtonCSSClass { get; set; }
167+
168+
private string filterButtonColorString => FilterButtonColor.ToButtonColorClass();
169+
150170
/// <summary>
151171
/// Gets or sets filter operator.
152172
/// </summary>

docs/docs/05-components/grid.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ Grid requires either `Data` or `DataProvider` parameter, but not both.
7878
| ChildContent | RenderFragment | null | ✔️ | Gets or sets the content to be rendered within the component. | 1.0.0 |
7979
| ColumnClass | `Func<TItem, string>?` | | | Gets or sets the column class. | 1.6.0 |
8080
| Filterable | bool | true | | If true, filter is enabled. The filter is enabled or disabled based on the grid `AllowFiltering` parameter. | 1.0.0 |
81+
| FilterButtonColor | `ButtonColor` | `ButtonColor.Light` | | Gets or sets the filter button color. | 3.0.0 |
82+
| FilterButtonCSSClass | `string?` | null | | Gets or sets the filter button CSS class. | 3.0.0 |
8183
| FilterOperator | `FilterOperator` | `FilterOperator.None` | | Gets or sets the filter operator. | 1.0.0 |
8284
| FilterTextboxWidth | int | 0 | | Gets or sets the filter textbox width in pixels. | 1.0.0 |
8385
| FilterValue | string | null | | Gets or sets the filter value. | 1.0.0 |

0 commit comments

Comments
 (0)