@@ -30,9 +34,10 @@ else
@* Sample using Property and OnSelect *@
Using Property and OnSelect
-
+
SelectedItems = People.Where(p => p.Selected);
diff --git a/src/Core/Components/DataGrid/Columns/SelectColumn.cs b/src/Core/Components/DataGrid/Columns/SelectColumn.cs
index 9e0fed801c..24882ac088 100644
--- a/src/Core/Components/DataGrid/Columns/SelectColumn.cs
+++ b/src/Core/Components/DataGrid/Columns/SelectColumn.cs
@@ -44,6 +44,13 @@ public SelectColumn()
[Parameter]
public bool SelectAllDisabled { get; set; } = false;
+ ///
+ /// Gets or sets whether the selection of rows is restricted to the SelectColumn (false) or if the whole row can be clicked to toggled the selection (true).
+ /// Default is True.
+ ///
+ [Parameter]
+ public bool SelectFromEntireRow { get; set; } = true;
+
///
/// Gets or sets the template for the [All] checkbox column template.
///
@@ -309,8 +316,12 @@ private RenderFragment GetDefaultChildContent()
builder.OpenComponent>(0);
builder.AddAttribute(1, "Value", GetIcon(selected));
- builder.AddAttribute(1, "Title", selected ? TitleChecked : TitleUnchecked);
- builder.AddAttribute(2, "row-selected", selected);
+ builder.AddAttribute(2, "Title", selected ? TitleChecked : TitleUnchecked);
+ builder.AddAttribute(3, "row-selected", selected);
+ if (!SelectFromEntireRow)
+ {
+ builder.AddAttribute(4, "style", "cursor: pointer;");
+ }
builder.CloseComponent();
});
}
diff --git a/src/Core/Components/DataGrid/FluentDataGrid.razor.cs b/src/Core/Components/DataGrid/FluentDataGrid.razor.cs
index 1db0749077..04917057be 100644
--- a/src/Core/Components/DataGrid/FluentDataGrid.razor.cs
+++ b/src/Core/Components/DataGrid/FluentDataGrid.razor.cs
@@ -124,6 +124,12 @@ public partial class FluentDataGrid : FluentComponentBase, IHandleEve
[Parameter]
public EventCallback> OnCellFocus { get; set; }
+ ///
+ /// Gets or sets a callback when a cell is clicked.
+ ///
+ [Parameter]
+ public EventCallback> OnCellClick { get; set; }
+
///
/// Gets or sets a callback when a row is clicked.
///
@@ -187,7 +193,7 @@ public partial class FluentDataGrid : FluentComponentBase, IHandleEve
// We cascade the InternalGridContext to descendants, which in turn call it to add themselves to _columns
// This happens on every render so that the column list can be updated dynamically
private readonly InternalGridContext _internalGridContext;
- private readonly List> _columns;
+ internal readonly List> _columns;
private bool _collectingColumns; // Columns might re-render themselves arbitrarily. We only want to capture them at a defined time.
// Tracking state for options and sorting
diff --git a/src/Core/Components/DataGrid/FluentDataGridCell.razor b/src/Core/Components/DataGrid/FluentDataGridCell.razor
index 5e05d90a24..e94605961d 100644
--- a/src/Core/Components/DataGrid/FluentDataGridCell.razor
+++ b/src/Core/Components/DataGrid/FluentDataGridCell.razor
@@ -6,6 +6,7 @@
grid-column=@GridColumn
class="@Class"
style="@StyleValue"
+ @onclick="@HandleOnCellClickAsync"
@attributes="AdditionalAttributes">
@ChildContent
diff --git a/src/Core/Components/DataGrid/FluentDataGridCell.razor.cs b/src/Core/Components/DataGrid/FluentDataGridCell.razor.cs
index ebd89b844e..ad3fa3cada 100644
--- a/src/Core/Components/DataGrid/FluentDataGridCell.razor.cs
+++ b/src/Core/Components/DataGrid/FluentDataGridCell.razor.cs
@@ -41,7 +41,7 @@ public partial class FluentDataGridCell : FluentComponentBase
/// Gets or sets the owning component.
///