LgGridNumericColumn
LgGridNumericColumn<TColumnValue> displays and edits numeric values with formatting, prefix, and suffix.
<Columns Context="item">
<LgGridNumericColumn @bind-Value="item.Amount"
Title="#Amount"
DisplayFormat="N2"
Prefix="€" />
</Columns>
- NuGet package:
Lagoon.UI.GridView
Common parameters are documented in LgGridBaseColumn.
Usage
Demonstration
Try this component in the Lagoon showcase.
Format, calculation, and prefix/suffix
@inherits LgPage
<LgGridView StateId="orders-numeric-column"
Items="_orders"
EditMode="GridEditMode.Cell"
Title="#OrdersGridTitle">
<Columns Context="item">
<LgGridTextColumn @bind-Value="item.Number" Title="#OrderNumber" />
<LgGridNumericColumn @bind-Value="item.Amount"
Title="#Amount"
DisplayFormat="N2"
Decimals="2"
Prefix="$"
PrefixType="InputLabelType.Text"
Suffix="#TaxExcluded"
SuffixType="InputLabelType.Text"
CalculationType="DataCalculationType.Sum"
CalculationDisplayFormat="N2" />
<LgGridNumericColumn @bind-Value="item.Weight"
Title="#Weight"
DisplayFormat="N1"
CalculationType="DataCalculationType.Average" />
</Columns>
</LgGridView>
This column's filter accepts only numeric values and can filter by value or by range.
Per-row prefix/suffix and weighted average
Because the <Columns> fragment is materialized only once, a Prefix/Suffix that depends on the row uses PrefixSelector / SuffixSelector (Func<TItem, string>), evaluated per row. For a weighted average (CalculationType="Average"), WeightSelector (Expression<Func<TItem, object>>) provides the weight per row — a typed replacement for the legacy WeightExpression, whose boxing node for a value-type key is removed to remain translatable to remote calculation.
@inherits LgPage
<LgGridView StateId="orders-numeric-selector" Items="_orders" Title="#OrdersGridTitle">
<Columns Context="item">
@* Currency per row, and weighted average rate per order amount. *@
<LgGridNumericColumn @bind-Value="item.Amount"
Title="#Amount"
DisplayFormat="N2"
SuffixSelector="i => i.CurrencyCode"
SuffixType="InputLabelType.Text" />
<LgGridNumericColumn @bind-Value="item.Rate"
Title="#Rate"
DisplayFormat="P2"
CalculationType="DataCalculationType.Average"
WeightSelector="@(i => i.Amount)" />
</Columns>
</LgGridView>
Filter
Numeric filter.
Associated enumerations
InputLabelType
Content type used by the PrefixType and SuffixType properties.
| Value | Description |
|---|---|
IconName | Interprets the value as an icon name. |
Text | Interprets the value as plain text (default value). |
DataCalculationType
Calculation type displayed in the column footer (inherited property CalculationType).
| Value | Description |
|---|---|
None | No calculation (default value). |
Count | Number of elements. |
Sum | Sum of values. |
Average | Average of values. |
Min | Minimum value. |
Max | Maximum value. |
Inherited edit modes (GridEditMode) are documented in LgGridView.
API sheet generated from the source code: API reference — LgGridNumericColumn.
Related components
LgGridView— the grid that hosts the column.LgGridTextColumn— base column and inherited common parameters.