Bind Columns
Grid Columns can be bound to the Smart.Grid by setting them as children of the Column component:
@inject WeatherForecastService ForecastService <Grid> <Columns> <Column DataField="Date" Label="Date"> </Column> <Column DataField="TemperatureC" Label="Temp. (C)"> </Column> <Column DataField="TemperatureF" Label="Temp. (F)"> </Column> <Column DataField="Summary" Label="Summary"> </Column> </Columns> </Grid> @code{ private WeatherForecast[] forecast; protected override async Task OnInitializedAsync() { forecast = await ForecastService.GetForecastAsync(DateTime.Now); } }
The most important properties of the Grid Column are DataField
, Label
and DataType
:
DataField
- specifies the property of the DataSource, which will be used as a value of the ColumnLabel
- specifies the Column Title, which the users will see when the Grid has been renderedDataType
- specifies the column's data type. The Possible values arestring | number | int | date | bool | object | any
DataType
is not required, it is recommended if you plan to use the Smart.Grid's Filtering & Sorting functionalities
Appearance
Align
- specifies the alignment of the column's header. The Possible values areHorizontalAlignment.Left | Right | Center
VerticalAlign
- specifies the vertical alignment of the column's header. The Possible values areVerticalAlignment.Center | Top | Bottom
CellsAlign
- specifies the column's cells alignment. The Possible values areHorizontalAlignment.Left | Right | Center
CellsVerticalAlign
- specifies the column's cells vertical alignment. The Possible values areVerticalAlignment.Center | Top | Bottom
CellsWrap
- specifies the column's cells wrapping. The Possible values aretrue | false
Description
- specifies the column's description, which is displaued when the end-user moves the pointer over the description buttonShowDescriptionButton
- specifies whether the description button is visible. The Possible values aretrue | false
Width
- specifies the width of the column. Value should benumber
MinWidth
- specifies the minimum width of the column. Value should benumber
Icon
- specifies the column's icon. Value should be CSS Class NameShowIcon
- specifies whether the Icon is visible. The Possible values aretrue | false
Visible
- specifies whether the column is visible. The Possible values aretrue | false
Formatting & Templates
CellsFormat
- specifies the column's cells format for numbers, dates and time. Value should bestring
FormatSettings
- specifies the format settings for numbers, dates and time. Value should beobject
The properrties of the object are based on either Intl.NumberFormat or Intl.DateTimeFormat ConstructorsTemplate
- specifies the column's template. The Possible values are theid
of HTMLTemplateElement or any of the built-in string values:
checkBox | switchButton | radioButton| url | email
Group
AllowGroup
- specifies whether the column can be grouped. The Possible values aretrue | false
ColumnGroup
- specifies the name of the column group
Note that Column Groups establish the hierarchy between the columnsGroup
- specifies the name of the column's group
Note that Groups establish the hierarchy between the rows
Filter
AllowFilter
- specifies whether the column can be filtered. The Possible values aretrue | false
Filter
- specifies the filter of the columnFilterMenuMode
- the filter menu mode of the column. The Possible values are:-
basic
- a single input is displayed in the filter menu -
default
- two input options are available for more precise filtering -
excel
- a checked list with unique values is displayed
-
Sort
AllowSort
- specifies whether the column can be sorted. The Possible values aretrue | false
SortOrder
- specifies the sort order of the column. The Possible values areGridColumnSortOrder.Null | Asc | Desc
Edit
AllowEdit
- specifies whether the column can be edited. The Possible values aretrue | false
AllowHeaderEdit
- specifies whether the column can be edited, when header editing is enabled. The Possible values aretrue | false
Editor
- specifies the column's editor. Expects an object with Template property.ValidationRules
- specifies the column's validation rules. Expects object with the following properrties:type
- required, specifies the type of the validation. The Possible values are
required | min | max | minLength | maxLength | email | null | requiredTrue | minDate | maxDate | pattern
value
- not required if type set torequired | requiredTrue
message
- optional, specifies the error message
Reorder
AllowReorder
- specifies whether the column can be reordered. The Possible values aretrue | false
Note that the reorder settings are set inside the Grid Behavior property.
Resize
AllowResize
- specifies whether the column can be resized. The Possible values aretrue | false
Note that the resize settings are set inside the Grid Behavior property.
Functionality
AllowExport
- specifies whether the column can be exported. The Possible values aretrue | false
AllowHide
- specifies whether the column can be hidden. The Possible values aretrue | false
AllowSelect
- specifies whether the column can be selected. The Possible values aretrue | false
Note that the selection settings are set inside the Grid Selection property.Freeze
- specifies whether the column is pinned/freezed. The Possible values arenear | far | false
Element
- gets the HTML Element. The property returns null when the column is not in the View.Summary
- specifies the column summary. The property should be set to an array with the following possible values:
sum | min | max | avg | count | median | stdev | stdevp | var | varp