Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

GridCustomizeElementEventArgs.VisibleIndex Property

The visible index of the processed row or row that contains the processed cell.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public int VisibleIndex { get; }

#Property Value

Type Description
Int32

The index.

#Remarks

This following code sample highlights alternating (odd) rows with a different style to enhance readability.

Run Demo: Alternating Row Style

razor
<DxGrid @ref="Grid" Data="@Data" CustomizeElement="Grid_CustomizeElement">
    <Columns> ... </Columns>
</DxGrid>

@code {
    object Data { get; set; }
    IGrid Grid { get; set; }

    void Grid_CustomizeElement(GridCustomizeElementEventArgs e) {
        if(e.ElementType == GridElementType.DataRow && e.VisibleIndex % 2 == 1) {
            e.CssClass = "alt-item";
        }
        if(e.ElementType == GridElementType.HeaderCell) {
            e.Style = "background-color: rgba(0, 0, 0, 0.08)";
            e.CssClass = "header-bold";
        }
    }
}
css
.alt-item > td:not(.dxbl-grid-empty-cell),
.alt-item > td:not(.dxbl-grid-indent-cell) {
    background-color: color-mix(in srgb, var(--bs-gray-300), transparent 50%);
}
.header-bold span {
    font-weight: 700;
}

DevExpress Blazor Grid - Alternating Row Style

For more information and examples, refer to the CustomizeElement event’s description.

See Also