Back to Devexpress

GridColumnHeaderCaptionTemplateContext.IsVirtualized Property

blazor-devexpress-dot-blazor-dot-gridcolumnheadercaptiontemplatecontext.md

latest3.6 KB
Original Source

GridColumnHeaderCaptionTemplateContext.IsVirtualized Property

Returns whether the column is being virtualized.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public bool IsVirtualized { get; }

Property Value

TypeDescription
Boolean

true if the column is virtualized; otherwise, false.

|

Remarks

You can activate horizontal virtual scrolling for the Grid component as follows:

  1. Set VirtualScrollingEnabled to true.
  2. Set VirtualScrollingMode to Columns or RowsAndColumns.

Once activated, the Grid displays only columns that are in the viewport and virtualizes all other columns. For virtualized data columns, the Grid component does not render column filter menus and sort glyphs. Use the IsVirtualized context property to render a specific caption while a column is virtualized.

The following code snippet displays Loading… captions for all virtualized columns:

razor
<DxGrid @ref="MyGrid"
        Data="GridData"
        FilterMenuButtonDisplayMode="GridFilterMenuButtonDisplayMode.Always"
        VirtualScrollingMode="GridVirtualScrollingMode.RowsAndColumns"
        VirtualScrollingEnabled="true">
    <Columns>
        <DxGridCommandColumn Width="80px">
            <HeaderTemplate Context="CaptionContext">
                @{
                    if (CaptionContext.IsVirtualized) {
                        <span>Loading...</span>
                    }
                    else {
                        <a class="oi oi-plus" @onclick="@(() => MyGrid.StartEditNewRowAsync())" 
                           class="link-decoration" href="javascript:void(0);"></a>
                    }
                }                                    
            </HeaderTemplate>
        </DxGridCommandColumn>

        <DxGridSelectionColumn Width="80px">
            <HeaderTemplate Context="CaptionContext">
                @{
                    if (CaptionContext.IsVirtualized) {
                        <span>Loading...</span>
                    }
                    else {
                        <DxButton Click="() => MyGrid.SelectAllOnPage()" Text="Select All" />
                    }
                }
            </HeaderTemplate>
        </DxGridSelectionColumn>
        @* ... *@
    </Columns>
    <ColumnHeaderCaptionTemplate Context="CaptionContext">
    @{
        if (CaptionContext.IsVirtualized) {
            <span>Loading...</span>
        }
        else {
            <span title="Click the header to sort data by this column.">
                @CaptionContext.Caption
            </span>
        }
    }  
    </ColumnHeaderCaptionTemplate>
</DxGrid>

@code {
    IGrid MyGrid;
    object GridData;
    // ...
}
css
.link-decoration {
    text-decoration: none;
}

See Also

GridColumnHeaderCaptionTemplateContext Class

GridColumnHeaderCaptionTemplateContext Members

DevExpress.Blazor Namespace