Skip to content

Commit

Permalink
CheckBox InputAttributes added
Browse files Browse the repository at this point in the history
  • Loading branch information
enchev committed Dec 6, 2023
1 parent 0c34028 commit 0ad1d57
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Radzen.Blazor/RadzenCheckBox.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
<div @ref="@Element" @attributes="Attributes" class="@GetCssClass()" @onkeypress=@OnKeyPress @onkeypress:preventDefault style="@Style" tabindex="@(Disabled || ReadOnly ? "-1" : $"{TabIndex}")" id="@GetId()">
<div class="rz-helper-hidden-accessible">
<input type="checkbox" @onchange=@Toggle value=@CheckBoxValue name=@Name id=@Name checked=@CheckBoxChecked
<input type="checkbox" @onchange=@Toggle value=@CheckBoxValue name=@Name id=@Name checked=@CheckBoxChecked @attributes="InputAttributes"
tabindex="-1" readonly="@ReadOnly">
</div>
<div class=@BoxClassList @onclick=@Toggle @onclick:preventDefault>
Expand Down
8 changes: 8 additions & 0 deletions Radzen.Blazor/RadzenCheckBox.razor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Radzen.Blazor.Rendering;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Radzen.Blazor
Expand All @@ -16,6 +17,13 @@ namespace Radzen.Blazor
/// </example>
public partial class RadzenCheckBox<TValue> : FormComponent<TValue>
{
/// <summary>
/// Specifies additional custom attributes that will be rendered by the input.
/// </summary>
/// <value>The attributes.</value>
[Parameter]
public IReadOnlyDictionary<string, object> InputAttributes { get; set; }

/// <summary>
/// Gets or sets a value indicating whether is tri-state (true, false or null).
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions RadzenBlazorDemos/Pages/DropDownDataGridMultiple.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<Columns>
<RadzenDropDownDataGridColumn Width="60px" Sortable="false">
<HeaderTemplate>
<RadzenCheckBox Disabled="@(!grid.AllowSelectAll)" TriState="false" TValue="bool" Value="@(customers.Any(c => values != null && values.Contains(c.CustomerID)))"
<RadzenCheckBox InputAttributes="@(new Dictionary<string,object>(){ { "aria-label", "select all" }})" Disabled="@(!grid.AllowSelectAll)" TriState="false" TValue="bool" Value="@(customers.Any(c => values != null && values.Contains(c.CustomerID)))"
Change="@(args => values = args ? grid.View.Cast<Customer>().Select(c => c.CustomerID) : values = Enumerable.Empty<string>())" />
</HeaderTemplate>
<Template Context="data">
<RadzenCheckBox TriState="false" Value="@(values != null && values.Contains(((Customer) data).CustomerID))"
<RadzenCheckBox InputAttributes="@(new Dictionary<string,object>(){ { "aria-label", "select item" }})" TriState="false" Value="@(values != null && values.Contains(((Customer) data).CustomerID))"
TValue="bool" Change=@(args => grid.SelectItem(data)) @onclick:stopPropagation/>
</Template>
</RadzenDropDownDataGridColumn>
Expand Down

0 comments on commit 0ad1d57

Please sign in to comment.