Skip to content

Commit 7872946

Browse files
committed
add click handler for treeviewitem when Template used with checkboxes
1 parent d7ef3cb commit 7872946

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Radzen.Blazor/RadzenTreeItem.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
@if (Template != null)
1717
{
18-
<div class=@LabelClass @onkeydown:stopPropagation>@Template(this)</div>
18+
<div class=@LabelClass @onkeydown:stopPropagation @onclick="@OnTemplateClick">@Template(this)</div>
1919
} else
2020
{
2121
<label for="@(GetHashCode())" class=@LabelClass>@Text</label>

Radzen.Blazor/RadzenTreeItem.razor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,5 +487,14 @@ await Tree.ItemContextMenu.InvokeAsync(new TreeItemContextMenuEventArgs()
487487
ShiftKey = args.ShiftKey
488488
});
489489
}
490+
491+
internal async Task OnTemplateClick(MouseEventArgs args)
492+
{
493+
if (Tree != null && Tree.AllowCheckBoxes && Checkable)
494+
{
495+
var currentValue = IsChecked();
496+
await CheckedChange(currentValue == true ? false : true);
497+
}
498+
}
490499
}
491500
}

0 commit comments

Comments
 (0)