Skip to content

Commit f784e74

Browse files
Nick-StantonSteveSandersonMS
authored andcommitted
Productize QuickGrid (#46573)
1 parent ca8dbd4 commit f784e74

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2459
-2
lines changed

AspNetCore.sln

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server
17641764
EndProject
17651765
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Http.Generators", "src\Http\Http.Extensions\gen\Microsoft.AspNetCore.Http.Generators.csproj", "{4730F56D-24EF-4BB2-AA75-862E31205F3A}"
17661766
EndProject
1767+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "QuickGrid", "QuickGrid", "{C406D9E0-1585-43F9-AA8F-D468AF84A996}"
1768+
EndProject
1769+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.QuickGrid", "src\Components\QuickGrid\Microsoft.AspNetCore.Components.QuickGrid\src\Microsoft.AspNetCore.Components.QuickGrid.csproj", "{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}"
1770+
EndProject
1771+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter", "src\Components\QuickGrid\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter\src\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter.csproj", "{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}"
1772+
EndProject
17671773
Global
17681774
GlobalSection(SolutionConfigurationPlatforms) = preSolution
17691775
Debug|Any CPU = Debug|Any CPU
@@ -10589,6 +10595,38 @@ Global
1058910595
{4730F56D-24EF-4BB2-AA75-862E31205F3A}.Release|x64.Build.0 = Release|Any CPU
1059010596
{4730F56D-24EF-4BB2-AA75-862E31205F3A}.Release|x86.ActiveCfg = Release|Any CPU
1059110597
{4730F56D-24EF-4BB2-AA75-862E31205F3A}.Release|x86.Build.0 = Release|Any CPU
10598+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
10599+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
10600+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Debug|arm64.ActiveCfg = Debug|Any CPU
10601+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Debug|arm64.Build.0 = Debug|Any CPU
10602+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Debug|x64.ActiveCfg = Debug|Any CPU
10603+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Debug|x64.Build.0 = Debug|Any CPU
10604+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Debug|x86.ActiveCfg = Debug|Any CPU
10605+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Debug|x86.Build.0 = Debug|Any CPU
10606+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
10607+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Release|Any CPU.Build.0 = Release|Any CPU
10608+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Release|arm64.ActiveCfg = Release|Any CPU
10609+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Release|arm64.Build.0 = Release|Any CPU
10610+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Release|x64.ActiveCfg = Release|Any CPU
10611+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Release|x64.Build.0 = Release|Any CPU
10612+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Release|x86.ActiveCfg = Release|Any CPU
10613+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2}.Release|x86.Build.0 = Release|Any CPU
10614+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
10615+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Debug|Any CPU.Build.0 = Debug|Any CPU
10616+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Debug|arm64.ActiveCfg = Debug|Any CPU
10617+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Debug|arm64.Build.0 = Debug|Any CPU
10618+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Debug|x64.ActiveCfg = Debug|Any CPU
10619+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Debug|x64.Build.0 = Debug|Any CPU
10620+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Debug|x86.ActiveCfg = Debug|Any CPU
10621+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Debug|x86.Build.0 = Debug|Any CPU
10622+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|Any CPU.ActiveCfg = Release|Any CPU
10623+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|Any CPU.Build.0 = Release|Any CPU
10624+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|arm64.ActiveCfg = Release|Any CPU
10625+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|arm64.Build.0 = Release|Any CPU
10626+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|x64.ActiveCfg = Release|Any CPU
10627+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|x64.Build.0 = Release|Any CPU
10628+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|x86.ActiveCfg = Release|Any CPU
10629+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|x86.Build.0 = Release|Any CPU
1059210630
EndGlobalSection
1059310631
GlobalSection(SolutionProperties) = preSolution
1059410632
HideSolutionNode = FALSE
@@ -11460,6 +11498,9 @@ Global
1146011498
{10173568-A65E-44E5-8C6F-4AA49D0577A1} = {F057512B-55BF-4A8B-A027-A0505F8BA10C}
1146111499
{97C7D2A4-87E5-4A4A-A170-D736427D5C21} = {F057512B-55BF-4A8B-A027-A0505F8BA10C}
1146211500
{4730F56D-24EF-4BB2-AA75-862E31205F3A} = {225AEDCF-7162-4A86-AC74-06B84660B379}
11501+
{C406D9E0-1585-43F9-AA8F-D468AF84A996} = {60D51C98-2CC0-40DF-B338-44154EFEE2FF}
11502+
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2} = {C406D9E0-1585-43F9-AA8F-D468AF84A996}
11503+
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931} = {C406D9E0-1585-43F9-AA8F-D468AF84A996}
1146311504
EndGlobalSection
1146411505
GlobalSection(ExtensibilityGlobals) = postSolution
1146511506
SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F}

eng/ProjectReferences.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@
141141
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Components" ProjectPath="$(RepoRoot)src\Components\Components\src\Microsoft.AspNetCore.Components.csproj" />
142142
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Components.CustomElements" ProjectPath="$(RepoRoot)src\Components\CustomElements\src\Microsoft.AspNetCore.Components.CustomElements.csproj" />
143143
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Components.Forms" ProjectPath="$(RepoRoot)src\Components\Forms\src\Microsoft.AspNetCore.Components.Forms.csproj" />
144+
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter" ProjectPath="$(RepoRoot)src\Components\QuickGrid\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter\src\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter.csproj" />
145+
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Components.QuickGrid" ProjectPath="$(RepoRoot)src\Components\QuickGrid\Microsoft.AspNetCore.Components.QuickGrid\src\Microsoft.AspNetCore.Components.QuickGrid.csproj" />
144146
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Components.Server" ProjectPath="$(RepoRoot)src\Components\Server\src\Microsoft.AspNetCore.Components.Server.csproj" />
145147
<ProjectReferenceProvider Include="Microsoft.Authentication.WebAssembly.Msal" ProjectPath="$(RepoRoot)src\Components\WebAssembly\Authentication.Msal\src\Microsoft.Authentication.WebAssembly.Msal.csproj" />
146148
<ProjectReferenceProvider Include="Microsoft.JSInterop.WebAssembly" ProjectPath="$(RepoRoot)src\Components\WebAssembly\JSInterop\src\Microsoft.JSInterop.WebAssembly.csproj" />

eng/TrimmableProjects.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
<TrimmableProject Include="Microsoft.AspNetCore.Components" />
8989
<TrimmableProject Include="Microsoft.AspNetCore.Components.CustomElements" />
9090
<TrimmableProject Include="Microsoft.AspNetCore.Components.Forms" />
91+
<TrimmableProject Include="Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter" />
92+
<TrimmableProject Include="Microsoft.AspNetCore.Components.QuickGrid" />
9193
<TrimmableProject Include="Microsoft.Authentication.WebAssembly.Msal" />
9294
<TrimmableProject Include="Microsoft.JSInterop.WebAssembly" />
9395
<TrimmableProject Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" />

src/Components/Components.slnf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"src\\Components\\CustomElements\\src\\Microsoft.AspNetCore.Components.CustomElements.csproj",
1515
"src\\Components\\Forms\\src\\Microsoft.AspNetCore.Components.Forms.csproj",
1616
"src\\Components\\Forms\\test\\Microsoft.AspNetCore.Components.Forms.Tests.csproj",
17+
"src\\Components\\QuickGrid\\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter\\src\\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter.csproj",
18+
"src\\Components\\QuickGrid\\Microsoft.AspNetCore.Components.QuickGrid\\src\\Microsoft.AspNetCore.Components.QuickGrid.csproj",
1719
"src\\Components\\Samples\\BlazorServerApp\\BlazorServerApp.csproj",
1820
"src\\Components\\Server\\src\\Microsoft.AspNetCore.Components.Server.csproj",
1921
"src\\Components\\Server\\test\\Microsoft.AspNetCore.Components.Server.Tests.csproj",
@@ -142,4 +144,4 @@
142144
"src\\WebEncoders\\src\\Microsoft.Extensions.WebEncoders.csproj"
143145
]
144146
}
145-
}
147+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Microsoft.AspNetCore.Components.QuickGrid;
5+
using Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter;
6+
7+
namespace Microsoft.Extensions.DependencyInjection;
8+
9+
/// <summary>
10+
/// Provides extension methods to configure <see cref="IAsyncQueryExecutor"/> on a <see cref="IServiceCollection"/>.
11+
/// </summary>
12+
public static class EntityFrameworkAdapterServiceCollectionExtensions
13+
{
14+
/// <summary>
15+
/// Registers an Entity Framework aware implementation of <see cref="IAsyncQueryExecutor"/>.
16+
/// </summary>
17+
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
18+
public static void AddQuickGridEntityFrameworkAdapter(this IServiceCollection services)
19+
{
20+
services.AddSingleton<IAsyncQueryExecutor, EntityFrameworkAsyncQueryExecutor>();
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Linq;
5+
using Microsoft.EntityFrameworkCore;
6+
using Microsoft.EntityFrameworkCore.Query;
7+
8+
namespace Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter;
9+
10+
internal sealed class EntityFrameworkAsyncQueryExecutor : IAsyncQueryExecutor
11+
{
12+
public bool IsSupported<T>(IQueryable<T> queryable)
13+
=> queryable.Provider is IAsyncQueryProvider;
14+
15+
public Task<int> CountAsync<T>(IQueryable<T> queryable)
16+
=> queryable.CountAsync();
17+
18+
public Task<T[]> ToArrayAsync<T>(IQueryable<T> queryable)
19+
=> queryable.ToArrayAsync();
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
5+
<Description>Provides an Entity Framework Core adapter for the <a href="https://www.nuget.org/packages/Microsoft.AspNetCore.Components.QuickGrid">Microsoft.AspNetCore.Components.QuickGrid</a> package.</Description>
6+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
7+
<IsTrimmable>true</IsTrimmable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<Reference Include="Microsoft.EntityFrameworkCore" />
12+
<Reference Include="Microsoft.AspNetCore.Components.QuickGrid" />
13+
</ItemGroup>
14+
15+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#nullable enable
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#nullable enable
2+
Microsoft.Extensions.DependencyInjection.EntityFrameworkAdapterServiceCollectionExtensions
3+
static Microsoft.Extensions.DependencyInjection.EntityFrameworkAdapterServiceCollectionExtensions.AddQuickGridEntityFrameworkAdapter(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> void
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.Components.QuickGrid;
5+
6+
/// <summary>
7+
/// Describes alignment for a <see cref="QuickGrid{TGridItem}"/> column.
8+
/// </summary>
9+
public enum Align
10+
{
11+
/// <summary>
12+
/// Justifies the content against the start of the container.
13+
/// </summary>
14+
Start,
15+
16+
/// <summary>
17+
/// Justifies the content at the center of the container.
18+
/// </summary>
19+
Center,
20+
21+
/// <summary>
22+
/// Justifies the content at the end of the container.
23+
/// </summary>
24+
End,
25+
26+
/// <summary>
27+
/// Justifies the content against the left of the container.
28+
/// </summary>
29+
Left,
30+
31+
/// <summary>
32+
/// Justifies the content at the right of the container.
33+
/// </summary>
34+
Right,
35+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
@using Microsoft.AspNetCore.Components.Rendering
2+
@using Microsoft.AspNetCore.Components.Web
3+
@using Microsoft.AspNetCore.Components.Web.Virtualization
4+
@namespace Microsoft.AspNetCore.Components.QuickGrid
5+
@typeparam TGridItem
6+
@{
7+
InternalGridContext.Grid.AddColumn(this, InitialSortDirection, IsDefaultSortColumn);
8+
}
9+
10+
@code
11+
{
12+
private void RenderDefaultHeaderContent(RenderTreeBuilder __builder)
13+
{
14+
@if (HeaderTemplate is not null)
15+
{
16+
@HeaderTemplate(this)
17+
}
18+
else
19+
{
20+
@if (ColumnOptions is not null && (Align != Align.Right || Align != Align.End))
21+
{
22+
<button class="col-options-button" @onclick="@(() => Grid.ShowColumnOptionsAsync(this))"></button>
23+
}
24+
25+
if (Sortable.HasValue ? Sortable.Value : IsSortableByDefault())
26+
{
27+
<button class="col-title" @onclick="@(() => Grid.SortByColumnAsync(this))">
28+
<div class="col-title-text">@Title</div>
29+
<div class="sort-indicator" aria-hidden="true"></div>
30+
</button>
31+
}
32+
else
33+
{
34+
<div class="col-title">
35+
<div class="col-title-text">@Title</div>
36+
</div>
37+
}
38+
39+
@if (ColumnOptions is not null && (Align == Align.Right || Align == Align.End))
40+
{
41+
<button class="col-options-button" @onclick="@(() => Grid.ShowColumnOptionsAsync(this))"></button>
42+
}
43+
}
44+
}
45+
46+
internal void RenderPlaceholderContent(RenderTreeBuilder __builder, PlaceholderContext placeholderContext)
47+
{
48+
// Blank if no placeholder template was supplied, as it's enough to style with CSS by default
49+
if (PlaceholderTemplate is not null)
50+
{
51+
@PlaceholderTemplate(placeholderContext)
52+
}
53+
}
54+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Microsoft.AspNetCore.Components.QuickGrid.Infrastructure;
5+
using Microsoft.AspNetCore.Components.Rendering;
6+
using Microsoft.AspNetCore.Components.Web.Virtualization;
7+
8+
namespace Microsoft.AspNetCore.Components.QuickGrid;
9+
10+
/// <summary>
11+
/// An abstract base class for columns in a <see cref="QuickGrid{TGridItem}"/>.
12+
/// </summary>
13+
/// <typeparam name="TGridItem">The type of data represented by each row in the grid.</typeparam>
14+
public abstract partial class ColumnBase<TGridItem>
15+
{
16+
[CascadingParameter] internal InternalGridContext<TGridItem> InternalGridContext { get; set; } = default!;
17+
18+
/// <summary>
19+
/// Title text for the column. This is rendered automatically if <see cref="HeaderTemplate" /> is not used.
20+
/// </summary>
21+
[Parameter] public string? Title { get; set; }
22+
23+
/// <summary>
24+
/// An optional CSS class name. If specified, this is included in the class attribute of table header and body cells
25+
/// for this column.
26+
/// </summary>
27+
[Parameter] public string? Class { get; set; }
28+
29+
/// <summary>
30+
/// If specified, controls the justification of table header and body cells for this column.
31+
/// </summary>
32+
[Parameter] public Align Align { get; set; }
33+
34+
/// <summary>
35+
/// An optional template for this column's header cell. If not specified, the default header template
36+
/// includes the <see cref="Title" /> along with any applicable sort indicators and options buttons.
37+
/// </summary>
38+
[Parameter] public RenderFragment<ColumnBase<TGridItem>>? HeaderTemplate { get; set; }
39+
40+
/// <summary>
41+
/// If specified, indicates that this column has this associated options UI. A button to display this
42+
/// UI will be included in the header cell by default.
43+
///
44+
/// If <see cref="HeaderTemplate" /> is used, it is left up to that template to render any relevant
45+
/// "show options" UI and invoke the grid's <see cref="QuickGrid{TGridItem}.ShowColumnOptionsAsync(ColumnBase{TGridItem})" />).
46+
/// </summary>
47+
[Parameter] public RenderFragment? ColumnOptions { get; set; }
48+
49+
/// <summary>
50+
/// Indicates whether the data should be sortable by this column.
51+
///
52+
/// The default value may vary according to the column type (for example, a <see cref="TemplateColumn{TGridItem}" />
53+
/// is sortable by default if any <see cref="TemplateColumn{TGridItem}.SortBy" /> parameter is specified).
54+
/// </summary>
55+
[Parameter] public bool? Sortable { get; set; }
56+
57+
/// <summary>
58+
/// Specifies sorting rules for a column.
59+
/// </summary>
60+
public abstract GridSort<TGridItem>? SortBy { get; set; }
61+
62+
/// <summary>
63+
/// Indicates which direction to sort in
64+
/// if <see cref="IsDefaultSortColumn"/> is true.
65+
/// </summary>
66+
[Parameter] public SortDirection InitialSortDirection { get; set; } = default;
67+
68+
/// <summary>
69+
/// Indicates whether this column should be sorted by default.
70+
/// </summary>
71+
[Parameter] public bool IsDefaultSortColumn { get; set; } = false;
72+
73+
/// <summary>
74+
/// If specified, virtualized grids will use this template to render cells whose data has not yet been loaded.
75+
/// </summary>
76+
[Parameter] public RenderFragment<PlaceholderContext>? PlaceholderTemplate { get; set; }
77+
78+
/// <summary>
79+
/// Gets a reference to the enclosing <see cref="QuickGrid{TGridItem}" />.
80+
/// </summary>
81+
public QuickGrid<TGridItem> Grid => InternalGridContext.Grid;
82+
83+
/// <summary>
84+
/// Overridden by derived components to provide rendering logic for the column's cells.
85+
/// </summary>
86+
/// <param name="builder">The current <see cref="RenderTreeBuilder" />.</param>
87+
/// <param name="item">The data for the row being rendered.</param>
88+
protected internal abstract void CellContent(RenderTreeBuilder builder, TGridItem item);
89+
90+
/// <summary>
91+
/// Gets or sets a <see cref="RenderFragment" /> that will be rendered for this column's header cell.
92+
/// This allows derived components to change the header output. However, derived components are then
93+
/// responsible for using <see cref="HeaderTemplate" /> within that new output if they want to continue
94+
/// respecting that option.
95+
/// </summary>
96+
protected internal RenderFragment HeaderContent { get; protected set; }
97+
98+
/// <summary>
99+
/// Get a value indicating whether this column should act as sortable if no value was set for the
100+
/// <see cref="ColumnBase{TGridItem}.Sortable" /> parameter. The default behavior is not to be
101+
/// sortable unless <see cref="ColumnBase{TGridItem}.Sortable" /> is true.
102+
///
103+
/// Derived components may override this to implement alternative default sortability rules.
104+
/// </summary>
105+
/// <returns>True if the column should be sortable by default, otherwise false.</returns>
106+
protected virtual bool IsSortableByDefault() => false;
107+
108+
/// <summary>
109+
/// Constructs an instance of <see cref="ColumnBase{TGridItem}" />.
110+
/// </summary>
111+
public ColumnBase()
112+
{
113+
HeaderContent = RenderDefaultHeaderContent;
114+
}
115+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Contains the title text and sort indicator, and expands to fill as much of the col width as it can */
2+
.col-title {
3+
display: flex; /* So that we can make col-title-text expand as much as possible, and still hide overflow with ellipsis */
4+
min-width: 0px;
5+
flex-grow: 1;
6+
padding: 0;
7+
}
8+
9+
/* If the column is sortable, its title is rendered as a button element for accessibility and to support navigation by tab */
10+
button.col-title {
11+
border: none;
12+
background: none;
13+
position: relative;
14+
cursor: pointer;
15+
}
16+
17+
.col-justify-center .col-title {
18+
justify-content: center;
19+
}
20+
21+
.col-justify-end .col-title {
22+
flex-direction: row-reverse; /* For end-justified cols, the sort indicator should appear before the title text */
23+
}
24+
25+
/* We put the column title text in its own element primarily so that it can use text-overflow: ellipsis */
26+
.col-title-text {
27+
text-overflow: ellipsis;
28+
overflow: hidden;
29+
white-space: nowrap;
30+
}

0 commit comments

Comments
 (0)