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

DxGrid.MakeDataItemVisibleAsync(Object) Method

Makes the row bound to the specified data item visible on screen.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public Task MakeDataItemVisibleAsync(
    object dataItem
)

#Parameters

Name Type Description
dataItem Object

A data item.

#Returns

Type Description
Task

The task that is completed when the row becomes visible.

#Remarks

Pass a data item to the MakeDataItemVisibleAsync method to make the row bound to this data item visible on screen. Once called, the method performs the following actions:

  1. If the row is in a collapsed group, expands the group.
  2. If the row is on another page, navigates to that page and updates the PageIndex property.
  3. Scrolls the Grid up or down until the row appears.

The MakeDataItemVisibleAsync method does nothing if no row corresponds to the passed data item or the corresponding row is filtered out.

The following code snippet navigates to the selected data row:

@using DxBlazorApplication.Data
@inject WeatherForecastService ForecastService

<DxButton Text="Go to the selected item" Click="ScrollToFirstSelectedItemAsync" />
<DxGrid @ref=Grid
        Data="@forecasts"
        AllowSelectRowByClick="true"
        @bind-SelectedDataItem="@SelectedDataItem"
        SelectionMode="GridSelectionMode.Single"
        KeyFieldName="Date">
    <Columns>
        <DxGridDataColumn FieldName="Date" />
        <DxGridDataColumn FieldName="TemperatureF" />
        <DxGridDataColumn FieldName="Summary" GroupIndex="0"/>
    </Columns>
</DxGrid>

@code {
    IGrid Grid;
    private WeatherForecast[]? forecasts;
    object SelectedDataItem { get; set; }

    async Task ScrollToFirstSelectedItemAsync() {
        if(SelectedDataItem != null)
            await Grid.MakeDataItemVisibleAsync(SelectedDataItem);
    }

    protected override async Task OnInitializedAsync() {
        forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
    }
}
See Also