HxGrid

Grid to display tabular data from data source. Includes support for client-side and server-side paging & sorting (or virtualized scrolling as needed).

Client-side data processing

  • Create a field/property for the data.
  • Set data to this field/property. Do not sort data.
  • Use the extension method ApplyTo (request.ApplyTo(data)) in the DataProvider method to automatically sort and page data from the field/property. While the result of the DataProvider method is a generic Task, the result must be wrapped using Task.FromResult. It is easy, see the demo source code.
LCIDDisplayNameNameEnglishName

Server side paging & sorting

  • Implement the DataProvider method to delegate the paging & sorting to the server side. The sample code does not have this implementation.
Display NameName

Empty data

Display NameName

Infinite scroll (Virtualized)

You can switch from paging to infinite-scoll by setting ContentNavigationMode="GridContentNavigationMode.InfiniteScroll". Use a Placeholder (<Placeholder>...</Placeholder>) to display content until the item data is available.

Display NameName

Context menu

LCIDDisplayNameNameEnglishName

Multiselect with checkboxes

You can let the user select multiple rows with MultiSelectionEnabled="true", selected items are represented by SelectedDataItems parameter (bindable).

LCIDDisplayNameNameEnglishName

Selected culture infos:

API

Parameters

Name Type Description
Columns RenderFragment Columns template.
ContentNavigationMode GridContentNavigationMode? Strategy how data are displayed in the grid (and loaded to the grid).
ContextMenu RenderFragment<TValue> Context menu template.
CurrentUserState GridUserState<TItem> Current grid state (page, sorting).
CurrentUserStateChanged EventCallback<TValue> Event fires when grid state is changed.
DataProvider GridDataProviderDelegate<TItem> Data provider for items to render as a table.
EmptyDataTemplate RenderFragment Template to render when there is empty Data (but not null).
FooterRowCssClass string Custom CSS class to render with footer tr element.
HeaderRowCssClass string Custom CSS class to render with header tr element.
InProgress bool? Indicates whether the grid should be displayed as "in progress". When null (default) value is used, grid is "in progress" when retrieving data by data provider.
ItemRowCssClass string Custom CSS class to render with data tr element.
ItemRowCssClassSelector Func<TItem, string> Returns custom CSS class to render with data tr element.
ItemRowHeight float? Height of the item row used for infinite scroll calculations. Default value is 41px (row-height of regular table-row within Bootstrap 5 default theme).
LoadingDataTemplate RenderFragment Template to render when "first" data are loading. This template is not used when loading data for sorting or paging operations.
MultiSelectionEnabled bool Indicates whether multi data items selection is enabled. Selection is performed by checkboxes in the first column. Can be combined with (single) selection. Default is false.
OverscanCount int? Infinite scroll: Gets or sets a value that determines how many additional items will be rendered before and after the visible region. This help to reduce the frequency of rendering during scrolling. However, higher values mean that more elements will be present in the page.
Default is 50.
PagerContainerCssClass string Custom CSS class to render with pager wrapping div element.
PageSize int? Page size.
PlaceholdersRowCount int? Number of rows with placeholders to render. When value is zero, placeholders are not used. When LoadingDataTemplate is set, placeholder are not used.
SelectedDataItem object Selected data item. Intended for data binding.
SelectedDataItemChanged EventCallback<TValue> Event fires when selected data item changes. Intended for data binding.
SelectedDataItems HashSet<TItem> Selected data items. Intended for data binding.
SelectedDataItemsChanged EventCallback<TValue> Event fires when selected data items changes. Intended for data binding.
SelectionEnabled bool Indicates whether single data item selection is enabled. Selection is performed by click on the item row. Can be combined with multiselection. Default is true.
ShowFooterWhenEmptyData bool? Indicates whether to render footer when data are empty.
TableContainerCssClass string Custom CSS class to render with div element wrapping the main table (HxPager is not wrapped in this div element).
TableCssClass string Custom CSS class to render with main table element.

Methods

Method Returns Description
RefreshDataAsync() Task Instructs the component to re-request data from its HxGrid.DataProvider. This is useful if external data may have changed.

Static properties

Property Type Description
Defaults GridDefaults Application-wide defaults for the HxGrid.

CSS Variables

Name Description Default
--hx-grid-button-hover-background Grid button background color on hover. var(--bs-gray-300)
--hx-grid-button-border-radius Grid button border radius. .2rem
--hx-grid-sorted-icon-color Color of the sorted icon. var(--bs-primary)

HxGridColumn

Grid column.

API

Parameters

Name Type Description
FooterCssClass string Footer cell css class.
FooterTemplate RenderFragment<GridFooterCellContext> Footer cell template.
FooterText string Footer cell text.
HeaderCssClass string Header cell css class.
HeaderTemplate RenderFragment<GridHeaderCellContext> Header cell template.
HeaderText string Header cell text.
IsDefaultSortColumn bool Indicates the sorting on the column is default (primary) on the grid. Set true for the column which is to be used for default sorting.
ItemCssClass string Returns item css class (not dependent on data).
ItemCssClassSelector Func<TItem, string> Returns item css class for the specific date item.
ItemTemplate RenderFragment<TValue> Returns template for the item.
ItemTextSelector Func<TItem, string> Returns text for the item.
PlaceholderTemplate RenderFragment<GridPlaceholderCellContext> Placeholder cell template.
SortDirection SortDirection Initial sorting direction. Default is SortDirection.Ascending.
SortKeySelector Expression<Func<object, IComparable>> Returns column sorting expression for automatic grid sorting. To be used for "strongly typed" setting of sorting, required for client-side sorting. Must be IComparable. Sorting of the column does not support multiple expressions. Create an artifcial property and implement IComparable.
SortString string Returns column sorting as string. Use to set sorting as a string, ie. to get value to pass to backend. Ignored for client-side sorting.
Visible bool Indicates whether the column is visible (otherwise the column is hidden).
An unhandled error has occurred. Reload 🗙