fluentui-blazor icon indicating copy to clipboard operation
fluentui-blazor copied to clipboard

[DataGrid] OnRowClick and SelectColumn together not as expected.

Open Rocky-25 opened this issue 2 years ago • 7 comments

🐛 Bug Report

If using a SelectColumn and OnRowClick when clicking the check box the row click event also fires. Can this not happen? Or can there be an option to turn it off?

🤔 Expected Behavior

When clicking the SelectColumn the RowClick handler shouldn't fire.

😯 Current Behavior

When clicking the SelectColumn the RowClick handler does fire.

🔦 Context

Using the grid and using on row click to navigate to the record, but have the option to select multiple records to then delete them or run another process.

🌍 Your Environment

.NET 8 Fluent UI Blazor library Version 4.8.1

Rocky-25 avatar Jun 25 '24 08:06 Rocky-25

Duplicate. See #2252

vnbaaij avatar Jun 25 '24 08:06 vnbaaij

I'm not sure this is a duplicate of that ticket as that is allowing a selection of a row from a row click and there is no OnRowClick event being used?

Rocky-25 avatar Jun 25 '24 08:06 Rocky-25

It allows you to restrict selection to clicking on the checkbox/radio button. Is that not what you are after?

vnbaaij avatar Jun 25 '24 08:06 vnbaaij

Let me 5min to verify if the OnRowClick is raised with this new feature

dvoituron avatar Jun 25 '24 08:06 dvoituron

Yes, using the new SelectFromEntireRow="false" attribute, the OnRowClick event is still triggered. But you will have a new OnCellClick event to detect which cell is clicked e.GridColumn. I think you could use this new event to detect which column to exclude.

<FluentDataGrid Items="@People" ShowHover="@SelectFromEntireRow" TGridItem="Person"
                OnRowClick="@(e => Console.WriteLine($"Row {e.RowIndex} clicked"))"
                OnCellClick="@(e => Console.WriteLine($"Cell on column {e.GridColumn} clicked"))">
Cell on column 2 clicked
Row 4 clicked

Cell on column 1 clicked
Row 4 clicked

dvoituron avatar Jun 25 '24 08:06 dvoituron

I'm after it so that we can have row click which does an action but when selecting a checkbox in the row it doesn't trigger the on row click as that can conflict. Also there could be buttons/inputs in the row so those would need to not propagate up to the row click event also.

Rocky-25 avatar Jun 25 '24 08:06 Rocky-25

@dvoituron thanks, OnCellClick sounds like it may do the job!

Rocky-25 avatar Jun 25 '24 09:06 Rocky-25