Skip to content
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 @@ -1241,6 +1241,12 @@
If not specified, the default header template includes the <see cref="P:Microsoft.FluentUI.AspNetCore.Components.ColumnBase`1.Title" /> along with any applicable sort indicators and options buttons.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.ColumnBase`1.HeaderCellTitleTemplate">
<summary>
Gets or sets a template for the title content of this column's header cell.
If not specified, the default header template includes the <see cref="P:Microsoft.FluentUI.AspNetCore.Components.ColumnBase`1.Title" />.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.ColumnBase`1.ColumnOptions">
<summary>
If specified, indicates that this column has this associated options UI. A button to display this
Expand Down Expand Up @@ -1350,6 +1356,14 @@
respecting that option.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.ColumnBase`1.HeaderTitleContent">
<summary>
Gets or sets a <see cref="T:Microsoft.AspNetCore.Components.RenderFragment" /> that will be rendered for this column's header title.
This allows derived components to change the header title output. However, derived components are then
responsible for using <see cref="P:Microsoft.FluentUI.AspNetCore.Components.ColumnBase`1.HeaderCellTitleTemplate" /> within that new output if they want to continue
respecting that option.
</summary>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.ColumnBase`1.IsSortableByDefault">
<summary>
Gets a value indicating whether this column should act as sortable if no value was set for the
Expand Down Expand Up @@ -2262,6 +2276,12 @@
</summary>
<returns></returns>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.ComputeItemsHash(System.Collections.Generic.IEnumerable{`0},System.Int32)">
<summary>
Computes a hash code for the given items.
To limit the effect on performance, only the given maximum number (default 250) of items will be considered.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentDataGridCell`1.Item">
<summary>
Gets or sets the reference to the item that holds this cell's values.
Expand Down
2 changes: 1 addition & 1 deletion examples/Demo/Shared/Pages/Menu/MenuPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<p>
With version 4.9.4 of the library, we introduced the <code>FluentMenuProvider</code> component. The Menu component has been updated to use this provider.
The <code>&lt;FluentMenuProvider /&gt;</code> needs to be placed at the <b>bottom</b> of your HTML page (just like the other <b>...Providers</b> components).
It will renders all menus (and menu items) at the provider location in the HTML structure. This allows for menus to appear <b>on top</b> other components.
It will render all menus (and menu items) at the provider location in the HTML structure. This allows for menus to appear <b>above</b> of other components.
</p>
<p>
You can disable this feature by adding the <code>UseMenuService</code> parameter (with a value of "false") to you FluentMenu component. In this case, the menu will be rendered at the location it is placed at in the page.
Expand Down
34 changes: 33 additions & 1 deletion src/Core/Components/DataGrid/FluentDataGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ public partial class FluentDataGrid<TGridItem> : FluentComponentBase, IHandleEve
// things have changed, and to discard earlier load attempts that were superseded.
private PaginationState? _lastRefreshedPaginationState;
private IQueryable<TGridItem>? _lastAssignedItems;
private int _lastAssignedItemsHashCode;
private GridItemsProvider<TGridItem>? _lastAssignedItemsProvider;
private CancellationTokenSource? _pendingDataLoadCancellationTokenSource;

Expand Down Expand Up @@ -434,14 +435,18 @@ protected override Task OnParametersSetAsync()
throw new InvalidOperationException($"FluentDataGrid cannot use both {nameof(Virtualize)} and {nameof(MultiLine)} at the same time.");
}

var currentItemsHash = FluentDataGrid<TGridItem>.ComputeItemsHash(Items);
var itemsChanged = currentItemsHash != _lastAssignedItemsHashCode;

// Perform a re-query only if the data source or something else has changed
var dataSourceHasChanged = !Equals(Items, _lastAssignedItems) || !Equals(ItemsProvider, _lastAssignedItemsProvider);
var dataSourceHasChanged = itemsChanged || !Equals(ItemsProvider, _lastAssignedItemsProvider);
if (dataSourceHasChanged)
{
_scope?.Dispose();
_scope = ScopeFactory.CreateAsyncScope();
_lastAssignedItemsProvider = ItemsProvider;
_lastAssignedItems = Items;
_lastAssignedItemsHashCode = currentItemsHash;
_asyncQueryExecutor = AsyncQueryExecutorSupplier.GetAsyncQueryExecutor(_scope.Value.ServiceProvider, Items);
}

Expand Down Expand Up @@ -1102,4 +1107,31 @@ public async Task ResetColumnWidthsAsync()
await Module.InvokeVoidAsync("resetColumnWidths", _gridReference);
}
}

/// <summary>
/// Computes a hash code for the given items.
/// To limit the effect on performance, only the given maximum number (default 250) of items will be considered.
/// </summary>
private static int ComputeItemsHash(IEnumerable<TGridItem>? items, int maxItems = 250)
{
if (items == null)
{
return 0;
}
unchecked
{
var hash = 19;
var count = 0;
foreach (var item in items)
{
if (++count > maxItems)
{
break;
}
hash = (hash * 31) + (item?.GetHashCode() ?? 0);
}
return hash;
}
}
}

Loading