Skip to content
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

Add item reference to FluentDataGridRow and FluentDataGridCell (#695) #700

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@

private void HandleRowFocus(FluentDataGridRow<Country> row)
{
Console.WriteLine($"Row focused: {row.RowIndex}");
Console.WriteLine($"Row focused: {row.Item?.Name}");
}
}
6 changes: 3 additions & 3 deletions src/Core/Components/DataGrid/FluentDataGrid.razor
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@
{
_rowsDataSize = $"height: {ItemSize}px";
}
<FluentDataGridRow @key="@(ItemKey(item))" GridTemplateColumns=@GridTemplateColumns aria-rowindex="@rowIndex" Class="@rowClass" Style="@_rowsDataSize" TGridItem="TGridItem">

<FluentDataGridRow @key="@(ItemKey(item))" GridTemplateColumns=@GridTemplateColumns aria-rowindex="@rowIndex" Class="@rowClass" Style="@_rowsDataSize" TGridItem="TGridItem" Item="@item">
@for (var colIndex = 0; colIndex < _columns.Count; colIndex++)
{
var col = _columns[colIndex];

<FluentDataGridCell GridColumn=@(colIndex+1) Class="@ColumnClass(col)" @key="@col" TGridItem="TGridItem">
<FluentDataGridCell GridColumn=@(colIndex+1) Class="@ColumnClass(col)" @key="@col" TGridItem="TGridItem" Item="@item">
@((RenderFragment)(__builder => col.CellContent(__builder, item)))
</FluentDataGridCell>
}
Expand Down
6 changes: 6 additions & 0 deletions src/Core/Components/DataGrid/FluentDataGridCell.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ public partial class FluentDataGridCell<TGridItem> : FluentComponentBase
{
internal string CellId { get; } = Identifier.NewId();

/// <summary>
/// Gets or sets the reference to the item that holds this cell's values
/// </summary>
[Parameter]
public TGridItem? Item { get; set; }

/// <summary>
/// Gets or sets the cell type. See <see cref="DataGridCellType"/>
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Core/Components/DataGrid/FluentDataGridRow.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ public partial class FluentDataGridRow<TGridItem> : FluentComponentBase, IHandle
internal string RowId { get; } = Identifier.NewId();
private readonly Dictionary<string, FluentDataGridCell<TGridItem>> cells = new();

/// <summary>
/// Gets or sets the reference to the item that holds this row's values
/// </summary>
[Parameter]
public TGridItem? Item { get; set; }

/// <summary>
/// Gets or sets the index of this row
/// When FluentDataGrid is virtualized, this value is not used
Expand Down