Skip to content
Open
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 @@ -21,13 +21,13 @@ public abstract partial class ColumnBase<TGridItem>
[Parameter] public string? Title { get; set; }

/// <summary>
/// An optional CSS class name. If specified, this is included in the class attribute of table header and body cells
/// An optional CSS class name. If specified, this is included in the class attribute of table header, body, and footer cells
/// for this column.
/// </summary>
[Parameter] public string? Class { get; set; }

/// <summary>
/// If specified, controls the justification of table header and body cells for this column.
/// If specified, controls the justification of table header, body, and footer cells for this column.
/// </summary>
[Parameter] public Align Align { get; set; }

Expand Down Expand Up @@ -76,6 +76,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="ColumnFooterTemplate"/>, the
/// grid will render a footer row in which each column renders its <see cref="ColumnFooterTemplate"/>.
/// </summary>
[Parameter] public RenderFragment? ColumnFooterTemplate { 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
@@ -1,3 +1,7 @@
#nullable enable
Microsoft.AspNetCore.Components.QuickGrid.Paginator.AdditionalAttributes.get -> System.Collections.Generic.IReadOnlyDictionary<string!, object!>?
Microsoft.AspNetCore.Components.QuickGrid.Paginator.AdditionalAttributes.set -> void
Microsoft.AspNetCore.Components.QuickGrid.ColumnBase<TGridItem>.ColumnFooterTemplate.get -> Microsoft.AspNetCore.Components.RenderFragment?
Microsoft.AspNetCore.Components.QuickGrid.ColumnBase<TGridItem>.ColumnFooterTemplate.set -> void
Microsoft.AspNetCore.Components.QuickGrid.QuickGrid<TGridItem>.GridFooterTemplate.get -> Microsoft.AspNetCore.Components.RenderFragment?
Microsoft.AspNetCore.Components.QuickGrid.QuickGrid<TGridItem>.GridFooterTemplate.set -> void
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
@{ StartCollectingColumns(); }
@ChildContent
<Defer>
@{ FinishCollectingColumns(); }
@{
FinishCollectingColumns();
var hasColumnFooters = _columns.Any(col => col.ColumnFooterTemplate is not null);
var hasGridFooter = GridFooterTemplate is not null;
var footerRowCount = (hasColumnFooters ? 1 : 0) + (hasGridFooter ? 1 : 0);
var ariaBodyRowCount = !Virtualize && Pagination is not null
? Math.Max(_ariaBodyRowCount, Pagination.ItemsPerPage)
: _ariaBodyRowCount;
}
<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 +42,25 @@
@_renderNonVirtualizedRows
}
</tbody>
@if (hasColumnFooters || hasGridFooter)
{
<tfoot>
@if (hasColumnFooters)
{
<tr aria-rowindex="@(ariaBodyRowCount + 2)">
@_renderColumnFooters
Comment thread
NanthiniMahalingam marked this conversation as resolved.
Resolved
</tr>
}
@if (hasGridFooter)
{
<tr aria-rowindex="@(ariaBodyRowCount + 2 + (hasColumnFooters ? 1 : 0))">
<td colspan="@_columns.Count" class="grid-footer-cell">
@GridFooterTemplate
</td>
</tr>
}
</tfoot>
}
</table>
</Defer>
</CascadingValue>
Expand Down Expand Up @@ -109,4 +136,12 @@
</th>
}
}

private void RenderColumnFooters(RenderTreeBuilder __builder)
{
foreach (var col in _columns)
{
<td class="grid-column-footer-cell @ColumnClass(col)" @key="@col">@col.ColumnFooterTemplate</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? GridFooterTemplate { get; set; }
Comment on lines +56 to +60

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the GridFooterTemplate public API addition needed? On the header side, QuickGrid has only the per-column ColumnBase.HeaderTemplate, with no grid-wide header template. What does a grid-level footer enable?


/// <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 @@ -203,6 +209,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 @@ -237,6 +244,7 @@ public QuickGrid()
_internalGridContext = new(this);
_currentPageItemsChanged = new(EventCallback.Factory.Create<PaginationState>(this, RefreshDataCoreAsync));
_renderColumnHeaders = RenderColumnHeaders;
_renderColumnFooters = RenderColumnFooters;
_renderNonVirtualizedRows = RenderNonVirtualizedRows;
_queryParameterValueSupplier = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
padding: 0.1rem 0.4rem;
}

.quickgrid[theme=default] > tbody > tr > td {
.quickgrid[theme=default] > tbody > tr > td,
.quickgrid[theme=default] > tfoot > tr > td {
padding: 0.1rem calc(0.4rem + var(--col-gap)) 0.1rem 0.4rem;
}

Expand Down
Loading
Loading