Skip to content
Closed
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 @@ -75,6 +75,13 @@ public abstract partial class ColumnBase<TGridItem>
/// </summary>
[Parameter] public RenderFragment<PlaceholderContext>? PlaceholderTemplate { get; set; }

/// <summary>
/// An optional template for this column's footer cell. If not specified, no footer cell content will
/// be rendered for this column. When any column in the grid has a <see cref="FooterTemplate"/>, the
/// grid will render a footer row in which each column renders its <see cref="FooterTemplate"/>.
/// </summary>
[Parameter] public RenderFragment? FooterTemplate { get; set; }

/// <summary>
/// Gets a reference to the enclosing <see cref="QuickGrid{TGridItem}" />.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ Microsoft.AspNetCore.Components.QuickGrid.QuickGrid<TGridItem>.AnchorMode.set ->
Microsoft.AspNetCore.Components.QuickGrid.QuickGrid<TGridItem>.ItemComparer.get -> System.Collections.Generic.IEqualityComparer<TGridItem>?
Microsoft.AspNetCore.Components.QuickGrid.QuickGrid<TGridItem>.ItemComparer.set -> void
*REMOVED*override Microsoft.AspNetCore.Components.QuickGrid.Paginator.OnParametersSet() -> void
Microsoft.AspNetCore.Components.QuickGrid.ColumnBase<TGridItem>.FooterTemplate.get -> Microsoft.AspNetCore.Components.RenderFragment?
Microsoft.AspNetCore.Components.QuickGrid.ColumnBase<TGridItem>.FooterTemplate.set -> void
Microsoft.AspNetCore.Components.QuickGrid.QuickGrid<TGridItem>.FooterTemplate.get -> Microsoft.AspNetCore.Components.RenderFragment?
Microsoft.AspNetCore.Components.QuickGrid.QuickGrid<TGridItem>.FooterTemplate.set -> void
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
@{ StartCollectingColumns(); }
@ChildContent
<Defer>
@{ FinishCollectingColumns(); }
@{
FinishCollectingColumns();
var hasColumnFooters = _columns.Any(col => col.FooterTemplate is not null);
var hasGridFooter = FooterTemplate is not null;
var footerRowCount = (hasColumnFooters ? 1 : 0) + (hasGridFooter ? 1 : 0);
}
<ColumnsCollectedNotifier TGridItem="TGridItem" />

<table theme="@Theme" aria-rowcount="@(_ariaBodyRowCount + 1)" @ref="_tableReference" @onclosecolumnoptions="HideColumnOptionsAsync" @attributes="AdditionalAttributes" class="@GridClass()">
<table theme="@Theme" aria-rowcount="@(_ariaBodyRowCount + 1 + footerRowCount)" @ref="_tableReference" @onclosecolumnoptions="HideColumnOptionsAsync" @attributes="AdditionalAttributes" class="@GridClass()">
<thead>
<tr>
@_renderColumnHeaders
Expand All @@ -34,6 +39,25 @@
@_renderNonVirtualizedRows
}
</tbody>
@if (hasColumnFooters || hasGridFooter)
{
<tfoot>
Comment thread
NanthiniMahalingam marked this conversation as resolved.
Resolved
@if (hasColumnFooters)
{
<tr aria-rowindex="@(_ariaBodyRowCount + 2)">
@_renderColumnFooters
</tr>
}
@if (hasGridFooter)
{
<tr aria-rowindex="@(_ariaBodyRowCount + 2 + (hasColumnFooters ? 1 : 0))">
<td colspan="@_columns.Count" class="grid-footer-cell">
@FooterTemplate
</td>
</tr>
}
</tfoot>
}
</table>
</Defer>
</CascadingValue>
Expand Down Expand Up @@ -108,4 +132,12 @@
</th>
}
}

private void RenderColumnFooters(RenderTreeBuilder __builder)
{
foreach (var col in _columns)
{
<td class="grid-column-footer-cell @ColumnClass(col)" @key="@col">@col.FooterTemplate</td>
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public partial class QuickGrid<TGridItem> : IAsyncDisposable
/// </summary>
[Parameter] public RenderFragment? ChildContent { get; set; }

/// <summary>
/// Optional. A template to render in the table footer area. If specified, the template will
/// be rendered inside a single &lt;tfoot&gt; row which spans all columns.
/// </summary>
[Parameter] public RenderFragment? FooterTemplate { get; set; }

/// <summary>
/// If true, the grid will be rendered with virtualization. This is normally used in conjunction with
/// scrolling and causes the grid to fetch and render only the data around the current scroll viewport.
Expand Down Expand Up @@ -202,6 +208,7 @@ public IEqualityComparer<TGridItem>? ItemComparer

// Caches of method->delegate conversions
private readonly RenderFragment _renderColumnHeaders;
private readonly RenderFragment _renderColumnFooters;
private readonly RenderFragment _renderNonVirtualizedRows;

// We try to minimize the number of times we query the items provider, since queries may be expensive
Expand Down Expand Up @@ -236,6 +243,7 @@ public QuickGrid()
_internalGridContext = new(this);
_currentPageItemsChanged = new(EventCallback.Factory.Create<PaginationState>(this, RefreshDataCoreAsync));
_renderColumnHeaders = RenderColumnHeaders;
_renderColumnFooters = RenderColumnFooters;
_renderNonVirtualizedRows = RenderNonVirtualizedRows;
_queryParameterValueSupplier = new();

Expand Down
Loading
Loading