Skip to main content

LgGridMonthColumn

LgGridMonthColumn<TColumnValue> is a LgGridView column specialized in the month of a date value: the default display format is MM/yyyy and editing opens the selector at the month level (like LgMonthBox).

<Columns Context="item">
<LgGridMonthColumn @bind-Value="item.BillingMonth" Title="#BillingMonth" />
</Columns>
  • Namespace : Lagoon.UI.Components
  • Inherits from : LgGridDateColumn<TColumnValue> → LgGridBaseValueColumn<TColumnValue> → LgGridBaseColumn
  • NuGet package : Lagoon.UI.GridView

Usage​

Demonstration​

Try this component in the Lagoon showcase.

Editable month column​

InvoiceListPage.razor
<LgGridView StateId="invoices-month-column"
Items="_invoices"
EditMode="GridEditMode.Cell"
Title="#InvoicesGridTitle">
<Columns Context="item">
<LgGridTextColumn @bind-Value="item.Number" Title="#InvoiceNumber" />
<LgGridMonthColumn @bind-Value="item.BillingMonth"
Title="#BillingMonth"
CanEdit="true" />
</Columns>
</LgGridView>
InvoiceListPage.razor.cs
public partial class InvoiceListPage : LgPage
{
// Rows displayed by the grid: the billing month is carried by a full date.
private readonly List<InvoiceVm> _invoices = new();

private sealed class InvoiceVm
{
public string Number { get; set; }
public DateTime? BillingMonth { get; set; }
}
}

Format, bounds, and calculation​

DisplayFormat replaces the default MM/yyyy format (e.g., MMMM yyyy for the month name). Min / Max limit the selection in the calendar. CalculationType displays a calculation in the column footer.

ContractListPage.razor
<LgGridView StateId="contracts-month-column" Items="_contracts" Title="#ContractsGridTitle">
<Columns Context="item">
<LgGridTextColumn @bind-Value="item.Reference" Title="#ContractReference" />
<LgGridMonthColumn @bind-Value="item.StartMonth"
Title="#StartMonth"
DisplayFormat="MMMM yyyy"
Min="_minDate"
Max="_maxDate"
CalculationType="DataCalculationType.Min" />
</Columns>
</LgGridView>
ContractListPage.razor.cs
public partial class ContractListPage : LgPage
{
// Authorized contract window: limits the month selector of cells in edit mode.
private readonly DateTime _minDate = new(2020, 1, 1);
private readonly DateTime _maxDate = new(2030, 12, 31);

private readonly List<ContractVm> _contracts = new();

private sealed class ContractVm
{
public string Reference { get; set; }
public DateTime? StartMonth { get; set; }
}
}

Properties​

All [Parameter] properties of the component, including inherited ones.

NameTypeDefaultDeclared inDescription
MaxDateTime?nullLgGridDateColumnLatest date selectable in edit mode; later dates are disabled.
MinDateTime?nullLgGridDateColumnEarliest date selectable in edit mode; 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 to update the bound value.
ValueExpressionExpression<Func<TColumnValue>>—LgGridBaseValueColumnExpression identifying the bound property (carries sort, filter, 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 of the calculation cell.
CalculationDisplayFormatstringnullLgGridBaseColumnDisplay format of the calculation cell.
CalculationTypeDataCalculationTypeNoneLgGridBaseColumnCalculation displayed in column footer (ignored without ValueExpression).
CanAddbooltrueLgGridBaseColumnAllows input of the column in the add row.
CanEditbooltrueLgGridBaseColumnAllows editing of column cells.
ColSpanint-1LgGridBaseColumnNumber of columns occupied by the cell.
ConfirmationMessagestringnullLgGridBaseColumnConfirmation message before modification (cell edit mode only).
CssClassstringnullLgGridBaseColumnCSS classes applied to all cells in the column.
DefaultFilterFilternullLgGridBaseFilterableColumnFilter applied by default.
DefaultFrozenboolfalseLgGridBaseColumnFreezes the column by default.
DefaultSortDirectionDataSortDirectionNoneLgGridBaseColumnDefault sort direction.
DefaultVisiblebooltrueLgGridBaseColumnDisplays the column by default.
DefaultWidthstring"1fr"LgGridBaseColumnDefault width of the column.
DisplayFormatstring"MM/yyyy"LgGridBaseColumnDisplay format of the value.
ExportablebooltrueLgGridBaseColumnIncludes the column in exports.
ExportTitlestringnullLgGridBaseColumnTitle used in export (Title by default).
ExportValueAsStringboolfalseLgGridBaseColumnForces the value to be exported as text.
FilterCellContentRenderFragment<FilterContext>nullLgGridBaseFilterableColumnCustom template of the filter cell.
FilterDisableSelectionboolfalseLgGridBaseFilterableColumnHides the value selection tab in the filter editor.
FilterExpressionLambdaExpressionnullLgGridBaseFilterableColumnFilter expression (ValueExpression is used by default).
FilterShowAllItemsbool?nullLgGridBaseFilterableColumnOffers all values in the filter, regardless of filters from other columns.
GroupExpressionLambdaExpressionnullLgGridBaseColumnGrouping expression.
GroupNamestringnullLgGridBaseColumnName of the column header group.
HeaderCellContentRenderFragmentnullLgGridBaseColumnCustom template of the header cell.
HeaderCssClassstringnullLgGridBaseColumnCSS classes of the header cell.
HeaderTooltipstringnullLgGridBaseColumnHeader tooltip.
HideContentboolfalseLgGridBaseColumnHides cell content.
KeystringnullLgGridBaseColumnUnique identifier of the column (deduced from ValueExpression if absent).
LambdaExpressionLambdaExpressionnullLgGridBaseColumnCommon sort and filter expression.
PlaceholderstringnullLgGridDateColumnPlaceholder text displayed in the cell editor.
MaxWidthint0LgGridBaseColumnMaximum width of the column.
MinSearchFilterCharacterint0LgGridBaseFilterableColumnMinimum number of characters before launching search in the filter.
MinWidthint0LgGridBaseColumnMinimum width of the column.
OnCellClickEventCallback<GridViewCellClickEventArgs<TItem>>—LgGridBaseColumnCallback triggered on click of 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 LgGridView — you do not need to define them.

Methods & events​

EventTypeDescription
OnCellClickEventCallback<GridViewCellClickEventArgs<TItem>>On click of a cell in the column.
ValueChangedEventCallback<TColumnValue>On modification of a cell value (@bind-Value).

Associated enumerations​

Inherited enumerations are documented on the base column: DataCalculationType and DataSortDirection on LgGridDateColumn, edit modes (GridEditMode) on LgGridView.

Best practices / accessibility​

  • The bound value remains a full date: only the month is displayed and edited. To input a month alone (int) in a form, use LgMonthBox.
  • The applied filter is a date filter: it operates on the full value, not just the displayed month.
Complete reference

Sheet generated from sources: API Reference — LgGridMonthColumn.