Skip to content

kb(Grid): prevent checkbox column click #3027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IvanDanchev
Copy link

Note to external contributors: make sure to sign our Contribution License Agreement (CLA) for Blazor UI first:

https://forms.office.com/Pages/ResponsePage.aspx?id=Z2om2-DLJk2uGtBYH-A1NbWxVqugKN5DvVp8I-1AgOBURFBVSkwyMlA1TkFDVFdMNU1aM1o1UlZQOC4u

@IvanDanchev IvanDanchev requested a review from a team as a code owner June 16, 2025 06:47
description: How to prevent an accidental click in the CheckBox column of the Grid
type: how-to
page_title: Grid CheckBox column prevent accidental click
slug: grid-checkbox-column-prevent-click
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We normally use -kb- in KB slugs to differentiate them.

Suggested change
slug: grid-checkbox-column-prevent-click
slug: grid-kb-checkbox-column-prevent-click

Comment on lines +79 to +83
private async Task OnRowClickHandler(GridRowClickEventArgs args)
{
// call a function that will prevent deselection of already selected rows
await JS.InvokeVoidAsync("handleDeselection");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic misses the first outside-the-checkbox click. Thus, attach the handler on initial component render and after rebind. The latter will be easier to achieve if using Grid OnRead.

Suggested change
private async Task OnRowClickHandler(GridRowClickEventArgs args)
{
// call a function that will prevent deselection of already selected rows
await JS.InvokeVoidAsync("handleDeselection");
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await Task.Delay(1);
await JS.InvokeVoidAsync("handleDeselection");
}
await base.OnAfterRenderAsync(firstRender);
}

@dimodi dimodi added the merge-to-production Use this label to get a comment to choose whether to merge the PR to production label Jun 16, 2025
Copy link
Contributor

Hello @dimodi,

Check the below option if you would like to automatically generate PR to production. The automation uses the branch for the cherry-pick, and then will delete the branch. Please, do not delete it manually.

  • create PR to production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-to-production Use this label to get a comment to choose whether to merge the PR to production
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants