Class
TelerikGrid<TItem>

The class for the Telerik Grid component.

Definition

Namespace:Telerik.Blazor.Components

Assembly:Telerik.Blazor.dll

Type Parameters:

TItem

The type of the model to which the grid is bound.

Syntax:

cs-api-definition
public class TelerikGrid<TItem> : TableGridBase<TItem, GridCommandEventArgs>, IComponent, IHandleEvent, IHandleAfterRender, IDisposable

Inheritance: objectComponentBaseBaseComponentDataBoundComponent<TItem>GridBase<TItem>TableGridBase<TItem, GridCommandEventArgs>TelerikGrid<TItem>

Implements: IComponentIDisposableIHandleAfterRenderIHandleEvent

Inherited Members TableGridBase<TItem, GridCommandEventArgs>._selectedItemsMapTableGridBase<TItem, GridCommandEventArgs>.OnAfterRender(bool)TableGridBase<TItem, GridCommandEventArgs>.Dispose()TableGridBase<TItem, GridCommandEventArgs>.SetMultiColumnHeaders()TableGridBase<TItem, GridCommandEventArgs>.OnParametersSet()TableGridBase<TItem, GridCommandEventArgs>.HandleVirtualScrollPaging()TableGridBase<TItem, GridCommandEventArgs>.SetSkip(int)TableGridBase<TItem, GridCommandEventArgs>.ResetEditContext()TableGridBase<TItem, GridCommandEventArgs>.PageData()TableGridBase<TItem, GridCommandEventArgs>.GetItemFromDropIndex(string)TableGridBase<TItem, GridCommandEventArgs>.GetItemFromDropIndex(int)TableGridBase<TItem, GridCommandEventArgs>.DialogFactoryTableGridBase<TItem, GridCommandEventArgs>.IdTableGridBase<TItem, GridCommandEventArgs>.ColumnVirtualizationTableGridBase<TItem, GridCommandEventArgs>.AutoGenerateColumnsTableGridBase<TItem, GridCommandEventArgs>.NavigableTableGridBase<TItem, GridCommandEventArgs>.RowTemplateTableGridBase<TItem, GridCommandEventArgs>.NoDataTemplateTableGridBase<TItem, GridCommandEventArgs>.ResizableTableGridBase<TItem, GridCommandEventArgs>.ReorderableTableGridBase<TItem, GridCommandEventArgs>.SortableTableGridBase<TItem, GridCommandEventArgs>.SortModeTableGridBase<TItem, GridCommandEventArgs>.FilterMenuTypeTableGridBase<TItem, GridCommandEventArgs>.SelectedItemsTableGridBase<TItem, GridCommandEventArgs>.SelectedItemsChangedTableGridBase<TItem, GridCommandEventArgs>.EnableLoaderContainerTableGridBase<TItem, GridCommandEventArgs>.RowDraggableTableGridBase<TItem, GridCommandEventArgs>.ConfirmDeleteTableGridBase<TItem, GridCommandEventArgs>.RowHeightTableGridBase<TItem, GridCommandEventArgs>.FilterRowDebounceDelayTableGridBase<TItem, GridCommandEventArgs>.ShowColumnMenuTableGridBase<TItem, GridCommandEventArgs>.OnCreateTableGridBase<TItem, GridCommandEventArgs>.OnUpdateTableGridBase<TItem, GridCommandEventArgs>.OnDeleteTableGridBase<TItem, GridCommandEventArgs>.OnEditTableGridBase<TItem, GridCommandEventArgs>.OnAddTableGridBase<TItem, GridCommandEventArgs>.OnCancelTableGridBase<TItem, GridCommandEventArgs>.IsPopupRenderingTableGridBase<TItem, GridCommandEventArgs>.CurrentBreakpointGridBase<TItem>.WidthGridBase<TItem>.HeightGridBase<TItem>.PageSizeChangedGridBase<TItem>.PageSizeGridBase<TItem>.PageGridBase<TItem>.PageChangedGridBase<TItem>.PageableGridBase<TItem>.OnModelInitGridBase<TItem>.TotalCountDataBoundComponent<TItem>.Rebind()DataBoundComponent<TItem>.DataBaseComponent.ShouldRender()BaseComponent.InitLocalizer()BaseComponent.ThrowIfParameterIsNull(object, string)BaseComponent.HaveOptionsChanged(IDictionary<string, object>, IDictionary<string, object>)BaseComponent.GetClassString(params string[])BaseComponent.InvokeAsync<T>(string, params object[])BaseComponent.InvokeAsync<T>(string, CancellationToken, params object[])BaseComponent.InvokeVoidAsync(string, params object[])BaseComponent.InvokeComponentMethodAsync<T>(string, params object[])BaseComponent.InvokeComponentMethodAsync<T>(string, CancellationToken, params object[])BaseComponent.InvokeVoidComponentMethodAsync(string, params object[])BaseComponent.InvokeComponentVoidMethodAsync(string, object)BaseComponent.InvokeDisposeAsync()BaseComponent.StateHasChanged()BaseComponent.RootComponentBaseComponent.ClassComponentBase.OnInitialized()ComponentBase.OnParametersSet()ComponentBase.OnAfterRender(bool)ComponentBase.InvokeAsync(Action)ComponentBase.InvokeAsync(Func<Task>)ComponentBase.DispatchExceptionAsync(Exception)

Constructors

TelerikGrid()

Declaration

cs-api-definition
public TelerikGrid()

Properties

AdaptiveMode

Defines the adaptive mode of the grid. The available values are None(default) and Auto. When set to auto and the width of the window is less than 768px or Medium, actionsheet is rendered for components that have popups.

Declaration

cs-api-definition
[Parameter]
public AdaptiveMode AdaptiveMode { get; set; }

Property Value

AdaptiveMode

DataLayoutMode

Defines the layout mode of the Grid. Use Stacked to enable the stacked layout with expandable rows showing additional data in a card-like format.

Declaration

cs-api-definition
[Parameter]
public GridDataLayoutMode DataLayoutMode { get; set; }

Property Value

GridDataLayoutMode

DetailTemplate

Template displayed in expandable rows below the main row data. Use this to create master-detail views with nested content for each row. Not compatible with virtual scrolling (Virtual).

Declaration

cs-api-definition
[Parameter]
public RenderFragment<TItem> DetailTemplate { get; set; }

Property Value

RenderFragment<TItem>

EditMode

Enables data editing and determines the editing interface. Use None to disable editing entirely, Inline to edit entire rows directly in the grid, Popup to open a modal dialog with edit form, or Incell to edit individual cells separately (not compatible with cell selection). The default mode is None.

Declaration

cs-api-definition
[Parameter]
public GridEditMode EditMode { get; set; }

Property Value

GridEditMode

FilterMode

Enables data filtering and determines the filter interface. Use None to disable filtering entirely, FilterRow to show inline filter controls below column headers, or FilterMenu to show filter options in dropdown menus accessed from column headers.

Declaration

cs-api-definition
[Parameter]
public GridFilterMode FilterMode { get; set; }

Property Value

GridFilterMode

GridExport

Contains export configuration for Excel, CSV, and PDF export functionality. Use this to enable data export from the Grid. Children: GridExcelExport, GridCsvExport, GridPdfExport.

Declaration

cs-api-definition
[Parameter]
public RenderFragment GridExport { get; set; }

Property Value

RenderFragment

GridPagerTemplate

Custom pager template that replaces the default pagination controls at the bottom of the Grid. Use this to create custom pagination UI.

Declaration

cs-api-definition
[Parameter]
public RenderFragment GridPagerTemplate { get; set; }

Property Value

RenderFragment

GridSettings

Contains additional Grid configuration options like pager, popup edit, row dragging, selection, and validation settings. Children: GridPagerSettings, GridPopupEditSettings, GridRowDraggableSettings, GridSelectionSettings, GridValidationSettings.

Declaration

cs-api-definition
[Parameter]
public RenderFragment GridSettings { get; set; }

Property Value

RenderFragment

GridToolBar

Contains predefined toolbar tools like Add, Export, Search, and Select All buttons that appear above the Grid columns. Cannot be used simultaneously with GridToolBarTemplate - choose either the strongly-typed toolbar or the custom template. Children: GridCommandButton, GridSearchBox, GridToolBarAddTool, GridToolBarCsvExportTool, GridToolBarExcelExportTool, GridToolBarSearchBoxTool, GridToolBarSelectAllTool, GridToolBarSpacerTool.

Declaration

cs-api-definition
[Parameter]
public RenderFragment GridToolBar { get; set; }

Property Value

RenderFragment

GridToolBarTemplate

Custom toolbar template that appears above the Grid columns. Use this to create custom toolbar content instead of predefined toolbar tools. Cannot be used simultaneously with GridToolBar - choose either the template or the strongly-typed toolbar.

Declaration

cs-api-definition
[Parameter]
public RenderFragment GridToolBarTemplate { get; set; }

Property Value

RenderFragment

Groupable

Enables data grouping by dragging column headers to a group panel and allows users to expand/collapse groups to organize data hierarchically. When using virtual scrolling (Virtual), grouping requires LoadGroupsOnDemand to be enabled. Programmatic grouping via SetStateAsync(GridState<TItem>) is always possible.

Declaration

cs-api-definition
[Parameter]
public bool Groupable { get; set; }

Property Value

bool

HighlightedCells

Collection of specific cells to visually highlight in the Grid. Use this to emphasize individual cells with different styling.

Declaration

cs-api-definition
[Parameter]
public List<GridHighlightedCellDescriptor> HighlightedCells { get; set; }

Property Value

List<GridHighlightedCellDescriptor>

HighlightedItems

Collection of data items to visually highlight in the Grid. Use this to emphasize specific rows with different styling.

Declaration

cs-api-definition
[Parameter]
public List<TItem> HighlightedItems { get; set; }

Property Value

List<TItem>

LoadGroupsOnDemand

Loads group data only when expanded by the user, improving performance with large grouped datasets. All groups start collapsed when enabled. This must be enabled when using Groupable with virtual scrolling (Virtual).

Declaration

cs-api-definition
[Parameter]
public bool LoadGroupsOnDemand { get; set; }

Property Value

bool

NewRowPosition

Controls where new rows appear when adding data. Set to Top to insert at the beginning or Bottom to insert at the end of the Grid. Default value is Top.

Declaration

cs-api-definition
[Parameter]
public GridNewRowPosition NewRowPosition { get; set; }

Property Value

GridNewRowPosition

OnRead

Fires when the Grid needs data from a remote source. Handle this event to implement custom data operations like paging, sorting, filtering, and grouping. sorting, filtering, grouping and paging. Once OnRead is attached, you must implement all such data source operations here. The Component will no longer perform them for you.

Declaration

cs-api-definition
[Parameter]
public EventCallback<GridReadEventArgs> OnRead { get; set; }

Property Value

EventCallback<GridReadEventArgs>

OnRowClick

Fires when user clicks on a Grid row or presses Enter while a row has focus. Use this to handle row selection or navigation.

Declaration

cs-api-definition
[Parameter]
public EventCallback<GridRowClickEventArgs> OnRowClick { get; set; }

Property Value

EventCallback<GridRowClickEventArgs>

OnRowCollapse

Fires when user collapses a detail row to hide nested content. Use this to clean up resources or track row collapse state.

Declaration

cs-api-definition
[Parameter]
public EventCallback<GridRowCollapseEventArgs> OnRowCollapse { get; set; }

Property Value

EventCallback<GridRowCollapseEventArgs>

OnRowContextMenu

Fires when user right-clicks on a Grid row or uses context menu key. Use this to display custom context menus for row actions.

Declaration

cs-api-definition
[Parameter]
public EventCallback<GridRowClickEventArgs> OnRowContextMenu { get; set; }

Property Value

EventCallback<GridRowClickEventArgs>

OnRowDoubleClick

Fires when user double-clicks on a Grid row. Use this to trigger actions like opening edit forms or navigation.

Declaration

cs-api-definition
[Parameter]
public EventCallback<GridRowClickEventArgs> OnRowDoubleClick { get; set; }

Property Value

EventCallback<GridRowClickEventArgs>

OnRowDrop

Fires when user completes dragging a Grid row to a new position. Enable RowDraggable to allow row reordering by drag and drop.

Declaration

cs-api-definition
[Parameter]
public EventCallback<GridRowDropEventArgs<TItem>> OnRowDrop { get; set; }

Property Value

EventCallback<GridRowDropEventArgs<TItem>>

OnRowExpand

Fires when user expands a detail row to show nested content. Use this to load detail data or track row expansion state.

Declaration

cs-api-definition
[Parameter]
public EventCallback<GridRowExpandEventArgs> OnRowExpand { get; set; }

Property Value

EventCallback<GridRowExpandEventArgs>

OnRowRender

Fires every time a Grid row is rendered. Use this to conditionally apply custom CSS classes or styling to rows based on data.

Declaration

cs-api-definition
[Parameter]
public Action<GridRowRenderEventArgs> OnRowRender { get; set; }

Property Value

Action<GridRowRenderEventArgs>

OnStateChanged

Fires whenever Grid state changes due to user actions like sorting, filtering, paging, or grouping. Use this to save state for persistence.

Declaration

cs-api-definition
[Parameter]
public EventCallback<GridStateEventArgs<TItem>> OnStateChanged { get; set; }

Property Value

EventCallback<GridStateEventArgs<TItem>>

OnStateInit

Fires during Grid initialization when state can be loaded from external storage. Use this to restore saved Grid settings like sorting and filtering. Useful when you'd like to persist changed on page reloads.

Declaration

cs-api-definition
[Parameter]
public EventCallback<GridStateEventArgs<TItem>> OnStateInit { get; set; }

Property Value

EventCallback<GridStateEventArgs<TItem>>

ScrollMode

Controls how the Grid handles large datasets. Use Scrollable for standard scrolling that renders all data and requires setting the Grid's Height, or Virtual for performance optimization with large datasets that renders only visible items during scrolling. When using Virtual, you must also set RowHeight and Height. Virtual scrolling is not compatible with Groupable (unless LoadGroupsOnDemand is true), Pageable, or DetailTemplate.

Declaration

cs-api-definition
[Parameter]
public GridScrollMode ScrollMode { get; set; }

Property Value

GridScrollMode

SelectedCells

Collection of currently selected cells when cell selection is enabled. Supports two-way binding for programmatic selection management.

Declaration

cs-api-definition
[Parameter]
public IEnumerable<GridSelectedCellDescriptor> SelectedCells { get; set; }

Property Value

IEnumerable<GridSelectedCellDescriptor>

SelectedCellsChanged

Fires when cell selection changes. Use this event to respond to user selecting or deselecting cells in the Grid.

Declaration

cs-api-definition
[Parameter]
public EventCallback<IEnumerable<GridSelectedCellDescriptor>> SelectedCellsChanged { get; set; }

Property Value

EventCallback<IEnumerable<GridSelectedCellDescriptor>>

SelectionMode

Enables row or cell selection and determines selection behavior. Use None to disable selection entirely, Single to allow selecting only one row at a time, or Multiple to enable multi-row selection with Ctrl+click and Shift+click.

Declaration

cs-api-definition
[Parameter]
public GridSelectionMode SelectionMode { get; set; }

Property Value

GridSelectionMode

Size

Controls the visual density and spacing of Grid rows and cells. Use Small, Medium, or Large to adjust padding and overall compactness. Default value is Medium.

Declaration

cs-api-definition
[Parameter]
public string Size { get; set; }

Property Value

string

Methods

AutoFitAllColumnsAsync()

Sets the minimum possible widths to all Grid columns, so that there is no text wrapping.

Declaration

cs-api-definition
public Task AutoFitAllColumnsAsync()

Returns

Task

AutoFitColumnAsync(string)

Sets the minimum possible width to a Grid column, so that there is no text wrapping.

Declaration

cs-api-definition
public Task AutoFitColumnAsync(string id)

Parameters

id

string

The Id value of the column to autofit.

Returns

Task

AutoFitColumnsAsync(IEnumerable<string>)

Sets the minimum possible widths to multiple Grid columns, so that there is no text wrapping.

Declaration

cs-api-definition
public Task AutoFitColumnsAsync(IEnumerable<string> ids)

Parameters

ids

IEnumerable<string>

The Id values of the columns to autofit.

Returns

Task

BuildRenderTree(RenderTreeBuilder)

Declaration

cs-api-definition
protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder

RenderTreeBuilder

Overrides ComponentBase.BuildRenderTree(RenderTreeBuilder)

Dispose()

Declaration

cs-api-definition
public override void Dispose()

Overrides TableGridBase<TItem, GridCommandEventArgs>.Dispose()

ExportToCsvAsync()

Exports the Grid to a MemoryStream that can be saved as a CSV file.

Declaration

cs-api-definition
public Task<MemoryStream> ExportToCsvAsync()

Returns

Task<MemoryStream>

ExportToCsvAsync(GridCsvExportOptions)

Exports the Grid to a MemoryStream that can be saved as a CSV file.

Declaration

cs-api-definition
public Task<MemoryStream> ExportToCsvAsync(GridCsvExportOptions options)

Parameters

options

GridCsvExportOptions

Returns

Task<MemoryStream>

ExportToExcelAsync()

Exports the Grid to a MemoryStream that can be saved as an Excel file.

Declaration

cs-api-definition
public Task<MemoryStream> ExportToExcelAsync()

Returns

Task<MemoryStream>

ExportToExcelAsync(GridExcelExportOptions)

Exports the Grid to a MemoryStream that can be saved as an Excel file.

Declaration

cs-api-definition
public Task<MemoryStream> ExportToExcelAsync(GridExcelExportOptions options)

Parameters

options

GridExcelExportOptions

Returns

Task<MemoryStream>

ExportToPdfAsync()

Exports the Grid to a MemoryStream that can be saved as a CSV file.

Declaration

cs-api-definition
public Task<MemoryStream> ExportToPdfAsync()

Returns

Task<MemoryStream>

GetAIRequest()

Get an AI request.

Declaration

cs-api-definition
public GridAIRequestDescriptor GetAIRequest()

Returns

GridAIRequestDescriptor

GetAIRequest(string)

Get an AI request.

Declaration

cs-api-definition
public GridAIRequestDescriptor GetAIRequest(string prompt)

Parameters

prompt

string

Returns

GridAIRequestDescriptor

GetAIResult(string)

Processes a Grid AI response.

Declaration

cs-api-definition
public GridAIResultDescriptor<TItem> GetAIResult(string aiResponseAsString)

Parameters

aiResponseAsString

string

Returns

GridAIResultDescriptor<TItem>

GetItemFromDropIndex(int)

Declaration

cs-api-definition
protected override TItem GetItemFromDropIndex(int index)

Parameters

index

int

Returns

TItem

Overrides TableGridBase<TItem, GridCommandEventArgs>.GetItemFromDropIndex(int)

GetState()

Gets the current state of the Grid. Includes grouping, filtering, edit items, column state, etc.

Declaration

cs-api-definition
public GridState<TItem> GetState()

Returns

GridState<TItem>

Instance of a GridState<TItem> class that contains all data.

OnAfterRenderAsync(bool)

Declaration

cs-api-definition
protected override Task OnAfterRenderAsync(bool firstRender)

Parameters

firstRender

bool

Returns

Task

Overrides BaseComponent.OnAfterRenderAsync(bool)

OnInitializedAsync()

Declaration

cs-api-definition
protected override Task OnInitializedAsync()

Returns

Task

Overrides BaseComponent.OnInitializedAsync()

OnParametersSetAsync()

Declaration

cs-api-definition
protected override Task OnParametersSetAsync()

Returns

Task

Overrides DataBoundComponent<TItem>.OnParametersSetAsync()

PageData()

Declaration

cs-api-definition
protected override Task PageData()

Returns

Task

Overrides TableGridBase<TItem, GridCommandEventArgs>.PageData()

ProcessAIResponseAsync(string)

Processes an AI request.

Declaration

cs-api-definition
public Task ProcessAIResponseAsync(string aiResponse)

Parameters

aiResponse

string

Returns

Task

SaveAsCsvFileAsync()

Exports the Grid to a file and sends it to the browser for download.

Declaration

cs-api-definition
public ValueTask SaveAsCsvFileAsync()

Returns

ValueTask

SaveAsCsvFileAsync(GridCsvExportOptions)

Exports the Grid to a file and sends it to the browser for download.

Declaration

cs-api-definition
public ValueTask SaveAsCsvFileAsync(GridCsvExportOptions options)

Parameters

options

GridCsvExportOptions

Returns

ValueTask

SaveAsExcelFileAsync()

Exports the grid to a file and sends it to the browser for download.

Declaration

cs-api-definition
public ValueTask SaveAsExcelFileAsync()

Returns

ValueTask

SaveAsExcelFileAsync(GridExcelExportOptions)

Exports the grid to a file and sends it to the browser for download.

Declaration

cs-api-definition
public ValueTask SaveAsExcelFileAsync(GridExcelExportOptions options)

Parameters

options

GridExcelExportOptions

Returns

ValueTask

SaveAsPdfFileAsync()

Exports the Grid to a file and sends it to the browser for download.

Declaration

cs-api-definition
public ValueTask SaveAsPdfFileAsync()

Returns

ValueTask

SetParametersAsync(ParameterView)

Declaration

cs-api-definition
public override Task SetParametersAsync(ParameterView parameters)

Parameters

parameters

ParameterView

Returns

Task

Overrides DataBoundComponent<TItem>.SetParametersAsync(ParameterView)

SetSkip(int)

Declaration

cs-api-definition
protected override void SetSkip(int skip)

Parameters

skip

int

Overrides TableGridBase<TItem, GridCommandEventArgs>.SetSkip(int)

SetStateAsync(GridState<TItem>)

Changes the state of the Grid. Includes all properties, which are controlled by the user - grouping, filtering, edit items, column state, etc.

Declaration

cs-api-definition
public Task SetStateAsync(GridState<TItem> state)

Parameters

state

GridState<TItem>

Returns

Task