LgGridYearColumn
LgGridYearColumn<TColumnValue> is a column of
LgGridView specialized in the year of a date
value: the default display format is yyyy and editing uses the
standard date picker.
<Columns Context="item">
<LgGridYearColumn @bind-Value="item.ConstructionDate" Title="#ConstructionYear" />
</Columns>
- Namespace:
Lagoon.UI.Components - Inherits from:
LgGridDateColumn<TColumnValue>→LgGridBaseValueColumn<TColumnValue>→LgGridBaseColumn - NuGet package:
Lagoon.UI.GridView
Usage
Demo
Try this component in the Lagoon showcase.
Year column
<LgGridView StateId="buildings-year-column"
Items="_buildings"
Title="#BuildingsGridTitle">
<Columns Context="item">
<LgGridTextColumn @bind-Value="item.Name" Title="#BuildingName" />
<LgGridYearColumn @bind-Value="item.ConstructionDate"
Title="#ConstructionYear" />
</Columns>
</LgGridView>
public partial class BuildingListPage : LgPage
{
// Rows displayed by the grid: the construction year is backed by a complete date.
private readonly List<BuildingVm> _buildings = new();
private sealed class BuildingVm
{
public string Name { get; set; }
public DateTime? ConstructionDate { get; set; }
}
}
Bounds and calculations
Min / Max constrain the selection in the cell calendar during editing;
CalculationType displays a calculation in the column footer.
<LgGridView StateId="vehicles-year-column"
Items="_vehicles"
EditMode="GridEditMode.Cell"
Title="#VehiclesGridTitle">
<Columns Context="item">
<LgGridTextColumn @bind-Value="item.Plate" Title="#VehiclePlate" />
<LgGridYearColumn @bind-Value="item.RegistrationDate"
Title="#RegistrationYear"
Min="_minDate"
CanEdit="true"
CalculationType="DataCalculationType.Max" />
</Columns>
</LgGridView>
public partial class VehicleListPage : LgPage
{
// Registrations before 1990 are not handled by the application.
private readonly DateTime _minDate = new(1990, 1, 1);
private readonly List<VehicleVm> _vehicles = new();
private sealed class VehicleVm
{
public string Plate { get; set; }
public DateTime? RegistrationDate { get; set; }
}
}
Properties
All [Parameter] properties of the component, including inherited ones.
| Name | Type | Default | Declared in | Description |
|---|---|---|---|---|
Max | DateTime? | null | LgGridDateColumn | The latest date selectable during editing; later dates are disabled. |
Min | DateTime? | null | LgGridDateColumn | The earliest date selectable during editing; earlier dates are disabled. |
CellContent | RenderFragment<TColumnValue> | null | LgGridBaseValueColumn | Custom template for the cell in display mode. |
CustomEditType | Type | null | LgGridBaseValueColumn | Component type used in edit mode instead of the default component. |
EditCellContent | RenderFragment<TColumnValue> | null | LgGridBaseValueColumn | Custom template for the cell in edit mode. |
Value | TColumnValue | — | LgGridBaseValueColumn | Bound value (@bind-Value). |
ValueChanged | EventCallback<TColumnValue> | — | LgGridBaseValueColumn | Callback for updating the bound value. |
ValueExpression | Expression<Func<TColumnValue>> | — | LgGridBaseValueColumn | Expression identifying the bound property (supports sorting, filtering, and calculations). |
AllowFilter | bool | true | LgGridBaseFilterableColumn | Enables the column filter (automatically disabled without a filter expression). |
AllowHide | bool | true | LgGridBaseColumn | Allows the user to hide the column. |
AllowSort | bool | true | LgGridBaseColumn | Enables column sorting (automatically disabled without a sort expression). |
AriaLabel | string | null | LgGridBaseColumn | Value of the column's aria-label attribute. |
AriaLabelledBy | string | null | LgGridBaseColumn | Value of the column's aria-labelledby attribute. |
CalculationCssClass | string | null | LgGridBaseColumn | CSS classes for the calculation cell. |
CalculationDisplayFormat | string | null | LgGridBaseColumn | Display format for the calculation cell. |
CalculationType | DataCalculationType | None | LgGridBaseColumn | Calculation displayed in the column footer (ignored without ValueExpression). |
CanAdd | bool | true | LgGridBaseColumn | Allows the column to receive input in the add row. |
CanEdit | bool | true | LgGridBaseColumn | Allows editing of the column cells. |
ColSpan | int | -1 | LgGridBaseColumn | Number of columns occupied by the cell. |
ConfirmationMessage | string | null | LgGridBaseColumn | Confirmation message before modification (cell editing only). |
CssClass | string | null | LgGridBaseColumn | CSS classes applied to all cells in the column. |
DefaultFilter | Filter | null | LgGridBaseFilterableColumn | Filter applied by default. |
DefaultFrozen | bool | false | LgGridBaseColumn | Freezes the column by default. |
DefaultSortDirection | DataSortDirection | None | LgGridBaseColumn | Default sort direction. |
DefaultVisible | bool | true | LgGridBaseColumn | Shows the column by default. |
DefaultWidth | string | "1fr" | LgGridBaseColumn | Default width of the column. |
DisplayFormat | string | "yyyy" | LgGridBaseColumn | Display format for the value. |
Exportable | bool | true | LgGridBaseColumn | Includes the column in exports. |
ExportTitle | string | null | LgGridBaseColumn | Title used in exports (the Title by default). |
ExportValueAsString | bool | false | LgGridBaseColumn | Forces exporting the value as text. |
FilterCellContent | RenderFragment<FilterContext> | null | LgGridBaseFilterableColumn | Custom template for the filter cell. |
FilterDisableSelection | bool | false | LgGridBaseFilterableColumn | Hides the value selection tab in the filter editor. |
FilterExpression | LambdaExpression | null | LgGridBaseFilterableColumn | Filter expression (if not set, ValueExpression is used). |
FilterShowAllItems | bool? | null | LgGridBaseFilterableColumn | Offers all values in the filter, independently of other columns' filters. |
GroupExpression | LambdaExpression | null | LgGridBaseColumn | Grouping expression. |
GroupName | string | null | LgGridBaseColumn | Name of the column header group. |
HeaderCellContent | RenderFragment | null | LgGridBaseColumn | Custom template for the header cell. |
HeaderCssClass | string | null | LgGridBaseColumn | CSS classes for the header cell. |
HeaderTooltip | string | null | LgGridBaseColumn | Header tooltip. |
HideContent | bool | false | LgGridBaseColumn | Hides cell contents. |
Key | string | null | LgGridBaseColumn | Unique identifier for the column (inferred from ValueExpression if absent). |
LambdaExpression | LambdaExpression | null | LgGridBaseColumn | Shared expression for sorting and filtering. |
Placeholder | string | null | LgGridDateColumn | Placeholder text displayed in the cell editor. |
MaxWidth | int | 0 | LgGridBaseColumn | Maximum width of the column. |
MinSearchFilterCharacter | int | 0 | LgGridBaseFilterableColumn | Minimum number of characters before launching a search in the filter. |
MinWidth | int | 0 | LgGridBaseColumn | Minimum width of the column. |
OnCellClick | EventCallback<GridViewCellClickEventArgs<TItem>> | — | LgGridBaseColumn | Callback triggered when clicking a cell in the column. |
Resizable | bool | true | LgGridBaseColumn | Allows column resizing. |
Title | string | null | LgGridBaseColumn | Column title. |
WeightExpression | LambdaExpression | null | LgGridBaseColumn | Weight expression for weighted average (CalculationType="Average"). |
The column receives its parent grid (LgGridView<TItem>) and its rendering context through cascading parameters provided by the LgGridView — you don't need to define them.
Methods & events
| Event | Type | Description |
|---|---|---|
OnCellClick | EventCallback<GridViewCellClickEventArgs<TItem>> | When clicking a cell in the column. |
ValueChanged | EventCallback<TColumnValue> | When a cell value changes (@bind-Value). |
Associated enumerations
Inherited enumerations are documented on the base column:
DataCalculationType and
DataSortDirection on
LgGridDateColumn, editing modes
(GridEditMode) on LgGridView.
Best practices / accessibility
- The bound value remains a complete date: only the year is displayed.
To input a year alone (
int) in a form, useLgYearBox. - The applied filter is a date filter: it applies to the complete value, not just the displayed year.
Reference generated from sources: API reference — LgGridYearColumn.
Related components
LgGridView— the data grid that hosts the column.LgGridDateColumn— base date column (day).LgGridMonthColumn— month column.LgGridWeekColumn— week column.LgYearBox— year input field (int) outside the grid.