Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.31k stars 533 forks source link

Datagrid callback and button callback happening at the same time #3716

Closed baltazarO closed 2 years ago

baltazarO commented 2 years ago

Hey guys! I got a problem that maybe you can help me with. I will describe it in detail.

Issue description:

I have a data grid with button(s) in each row. I want to click a button but not the row. Currently what happens is when I click the button itself, the data grid row and the button get selected. These buttons are for recording timestamps.

The reason this is a problem is because the button has an event callback and the data grid's selectedrowchanged has a event callback too. Both of the functions query the database at the same time using entity framework dbcontext. And because of the problem, I am running into backend problems (concurrency issues).

It would be great if the button's eventcallback was executed only.

Steps to reproduce issue

  1. Run Blazor web app in visual studio
  2. Click on a button in the data grid, but no where else in the data grid

Expected result

Button click submits DateTime.Now to the database Data grid row is not selected

Actual result

Data grid row is also selected App crashes due to concurrency issues (yellow box appears saying to reload the app)

Additional details

Windows 10 Intel Core i5 PC x-64 processor Blazorise (Components, DataGrid, Icons.Material, Material) 0.9.5.6 Visual studio 2022 .NET 6.0

Screenshots

Before:

image

After:

image

stsrki commented 2 years ago

Can you try stopping the event from bubbling up?

Example <Button Clicked="..." @onclick:stopPropagation>END DRY</Button>

David-Moreira commented 2 years ago

Also we introduced a new column parameter to handle these cases could you try it?

From our docs :

PreventRowClick Will set @onclick:StopProgration to true, stopping the RowClick and consequent events from triggering.
baltazarO commented 2 years ago

Hello! Thanks for replying. I will try it guys.

baltazarO commented 2 years ago

It work thanks!

stsrki commented 2 years ago

Glad we could help :)