diff --git a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor index 7f62954cf0..90e361ed98 100644 --- a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor +++ b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor @@ -214,9 +214,9 @@ @code { private RenderFragment paginationFragment => __builder => - { - <_DataGridPagination TItem="TItem" PaginationContext="@PaginationContext" PaginationTemplates="@PaginationTemplates" OnPaginationItemClick="@(EventCallback.Factory.Create(this, Paginate))" SelectedRow="@SelectedRow" /> - }; + { + <_DataGridPagination TItem="TItem" PaginationContext="@PaginationContext" PaginationTemplates="@PaginationTemplates" OnPaginationItemClick="@(EventCallback.Factory.Create(this, Paginate))" SelectedRow="@SelectedRow" /> + }; protected RenderFragment rowFragment => item => __builder => { @@ -226,7 +226,7 @@ } else { - <_DataGridRow @key="@item" TItem="TItem" Item="@item" /> + <_DataGridRow @key="@item" TItem="TItem" Item="@item" SelectedRows="SelectedRows" SelectedRow="SelectedRow" /> if ( DetailRowTemplate != null && ( GetRowInfo( item )?.HasDetailRow ?? false ) ) { <_DataGridDetailRow TItem="TItem" Item="@item" Columns="@Columns"> diff --git a/Source/Extensions/Blazorise.DataGrid/_DataGridRow.razor.cs b/Source/Extensions/Blazorise.DataGrid/_DataGridRow.razor.cs index 58df661647..786b8aec24 100644 --- a/Source/Extensions/Blazorise.DataGrid/_DataGridRow.razor.cs +++ b/Source/Extensions/Blazorise.DataGrid/_DataGridRow.razor.cs @@ -59,6 +59,12 @@ public override Task SetParametersAsync( ParameterView parameters ) case nameof( ParentDataGrid ): ParentDataGrid = (DataGrid)parameter.Value; break; + case nameof( SelectedRow ): + SelectedRow = (TItem)parameter.Value; + break; + case nameof( SelectedRows ): + SelectedRows = (List)parameter.Value; + break; default: throw new ArgumentException( $"Unknown parameter: {parameter.Name}" ); } @@ -248,6 +254,16 @@ protected string GetStyle( DataGridRowStyling styling, DataGridRowStyling select [Parameter] public RenderFragment ChildContent { get; set; } + /// + /// Gets or sets currently selected row. + /// + [Parameter] public TItem SelectedRow { get; set; } + + /// + /// Gets or sets currently selected rows. + /// + [Parameter] public List SelectedRows { get; set; } + #endregion } } \ No newline at end of file