Class TooltipTemplateContext
Provides contextual information for customizing tooltip content in the Blazor DataGrid via the TooltipTemplate.
Inheritance
Namespace: Syncfusion.Blazor.Grids
Assembly: Syncfusion.Blazor.dll
Syntax
public class TooltipTemplateContext : Object
Remarks
This context is passed to the TooltipTemplate to enable dynamic rendering of tooltip content based on the hovered cell.
The context includes details such as the cell value, row and column indices, associated data object, and column metadata.
When hovering over a content cell, the RowIndex will be a non-negative value and Data will contain the corresponding data object.
When hovering over a header cell, RowIndex will be -1
and Data will be null.
These properties can be used to apply conditional styling or logic within the tooltip template, allowing differentiation between header and content cells.
Examples
<SfGrid DataSource="@Orders" ShowTooltip="true">
<GridTemplates>
<TooltipTemplate>
@{
var tooltip = context as TooltipTemplateContext;
@if (tooltip.RowIndex == -1)
{
@tooltip.Value
}
else {
@tooltip.Column.Field
}
}
</TooltipTemplate>
</GridTemplates>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID"></GridColumn>
</GridColumns>
</SfGrid>
Constructors
TooltipTemplateContext()
Declaration
public TooltipTemplateContext()
Properties
Column
Gets the GridColumn associated with the currently hovered cell.
Declaration
public GridColumn Column { get; }
Property Value
Type | Description |
---|---|
GridColumn | The GridColumn object containing details such as header text, field name, and formatting options. |
Remarks
This property provides metadata about the column, such as field name, header text, and formatting options, which can be used to customize tooltip content.
ColumnIndex
Gets the column index of the currently hovered column.
Declaration
public int ColumnIndex { get; }
Property Value
Type | Description |
---|---|
System.Int32 | An integer representing the column index of the hovered cell. |
Data
Gets the data object of the currently hovered row.
Declaration
public object Data { get; }
Property Value
Type | Description |
---|---|
System.Object | The data associated with the hovered row. Returns |
Remarks
This object provides access to the full row data, enabling dynamic tooltip content based on multiple fields or business logic.
When hovering over a content cell, this property returns the corresponding row object.
For header cells, it always returns null
. This distinction is useful for customizing tooltip styles or behavior
based on whether the hovered element is a header or a content cell.
RowIndex
Gets the index of the currently hovered row.
Declaration
public int RowIndex { get; }
Property Value
Type | Description |
---|---|
System.Int32 | An System.Int32 representing the row index. Returns |
Remarks
When hovering over a content cell, this property returns the corresponding row index within the grid.
For header cells, it always returns -1
. This distinction is useful for customizing tooltip styles or behavior based on whether the hovered element is a header or a content cell.
Value
Gets the value of the currently hovered cell.
Declaration
public string Value { get; }
Property Value
Type | Description |
---|---|
System.String | A System.String representing the value displayed in the cell. The default value is null. |
Remarks
This value is useful for displaying raw or formatted data in the tooltip. For templated columns or special display types like DisplayAsCheckbox
, it reflects the underlying data value.
Applicable for both header and content cells. When hovering over a header cell, this property returns the column's HeaderText
. For content cells, it returns the corresponding cell value.