Skip to main content

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​

BuildingListPage.razor
<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>
BuildingListPage.razor.cs
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.

VehicleListPage.razor
<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>
VehicleListPage.razor.cs
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.

NameTypeDefaultDeclared inDescription
MaxDateTime?nullLgGridDateColumnThe latest date selectable during editing; later dates are disabled.
MinDateTime?nullLgGridDateColumnThe earliest date selectable during editing; earlier dates are disabled.
CellContentRenderFragment<TColumnValue>nullLgGridBaseValueColumnCustom template for the cell in display mode.
CustomEditTypeTypenullLgGridBaseValueColumnComponent type used in edit mode instead of the default component.
EditCellContentRenderFragment<TColumnValue>nullLgGridBaseValueColumnCustom template for the cell in edit mode.
ValueTColumnValue—LgGridBaseValueColumnBound value (@bind-Value).
ValueChangedEventCallback<TColumnValue>—LgGridBaseValueColumnCallback for updating the bound value.
ValueExpressionExpression<Func<TColumnValue>>—LgGridBaseValueColumnExpression identifying the bound property (supports sorting, filtering, and calculations).
AllowFilterbooltrueLgGridBaseFilterableColumnEnables the column filter (automatically disabled without a filter expression).
AllowHidebooltrueLgGridBaseColumnAllows the user to hide the column.
AllowSortbooltrueLgGridBaseColumnEnables column sorting (automatically disabled without a sort expression).
AriaLabelstringnullLgGridBaseColumnValue of the column's aria-label attribute.
AriaLabelledBystringnullLgGridBaseColumnValue of the column's aria-labelledby attribute.
CalculationCssClassstringnullLgGridBaseColumnCSS classes for the calculation cell.
CalculationDisplayFormatstringnullLgGridBaseColumnDisplay format for the calculation cell.
CalculationTypeDataCalculationTypeNoneLgGridBaseColumnCalculation displayed in the column footer (ignored without ValueExpression).
CanAddbooltrueLgGridBaseColumnAllows the column to receive input in the add row.
CanEditbooltrueLgGridBaseColumnAllows editing of the column cells.
ColSpanint-1LgGridBaseColumnNumber of columns occupied by the cell.
ConfirmationMessagestringnullLgGridBaseColumnConfirmation message before modification (cell editing only).
CssClassstringnullLgGridBaseColumnCSS classes applied to all cells in the column.
DefaultFilterFilternullLgGridBaseFilterableColumnFilter applied by default.
DefaultFrozenboolfalseLgGridBaseColumnFreezes the column by default.
DefaultSortDirectionDataSortDirectionNoneLgGridBaseColumnDefault sort direction.
DefaultVisiblebooltrueLgGridBaseColumnShows the column by default.
DefaultWidthstring"1fr"LgGridBaseColumnDefault width of the column.
DisplayFormatstring"yyyy"LgGridBaseColumnDisplay format for the value.
ExportablebooltrueLgGridBaseColumnIncludes the column in exports.
ExportTitlestringnullLgGridBaseColumnTitle used in exports (the Title by default).
ExportValueAsStringboolfalseLgGridBaseColumnForces exporting the value as text.
FilterCellContentRenderFragment<FilterContext>nullLgGridBaseFilterableColumnCustom template for the filter cell.
FilterDisableSelectionboolfalseLgGridBaseFilterableColumnHides the value selection tab in the filter editor.
FilterExpressionLambdaExpressionnullLgGridBaseFilterableColumnFilter expression (if not set, ValueExpression is used).
FilterShowAllItemsbool?nullLgGridBaseFilterableColumnOffers all values in the filter, independently of other columns' filters.
GroupExpressionLambdaExpressionnullLgGridBaseColumnGrouping expression.
GroupNamestringnullLgGridBaseColumnName of the column header group.
HeaderCellContentRenderFragmentnullLgGridBaseColumnCustom template for the header cell.
HeaderCssClassstringnullLgGridBaseColumnCSS classes for the header cell.
HeaderTooltipstringnullLgGridBaseColumnHeader tooltip.
HideContentboolfalseLgGridBaseColumnHides cell contents.
KeystringnullLgGridBaseColumnUnique identifier for the column (inferred from ValueExpression if absent).
LambdaExpressionLambdaExpressionnullLgGridBaseColumnShared expression for sorting and filtering.
PlaceholderstringnullLgGridDateColumnPlaceholder text displayed in the cell editor.
MaxWidthint0LgGridBaseColumnMaximum width of the column.
MinSearchFilterCharacterint0LgGridBaseFilterableColumnMinimum number of characters before launching a search in the filter.
MinWidthint0LgGridBaseColumnMinimum width of the column.
OnCellClickEventCallback<GridViewCellClickEventArgs<TItem>>—LgGridBaseColumnCallback triggered when clicking a cell in the column.
ResizablebooltrueLgGridBaseColumnAllows column resizing.
TitlestringnullLgGridBaseColumnColumn title.
WeightExpressionLambdaExpressionnullLgGridBaseColumnWeight expression for weighted average (CalculationType="Average").
Cascading parameters

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​

EventTypeDescription
OnCellClickEventCallback<GridViewCellClickEventArgs<TItem>>When clicking a cell in the column.
ValueChangedEventCallback<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, use LgYearBox.
  • The applied filter is a date filter: it applies to the complete value, not just the displayed year.
Complete reference

Reference generated from sources: API reference — LgGridYearColumn.