Back to Devexpress

DxGrid.MakeRowVisible(Int32) Method

blazor-devexpress-dot-blazor-dot-dxgrid-dot-makerowvisible-x28-system-dot-int32-x29.md

latest4.5 KB
Original Source

DxGrid.MakeRowVisible(Int32) Method

Makes the row with the specified visible index visible on screen.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public void MakeRowVisible(
    int visibleIndex
)

Parameters

NameTypeDescription
visibleIndexInt32

A row visible index.

|

Remarks

Row visible indexes indicate the order of visible data rows and group rows. Indexes are zero-based and sequential for rows on all grid pages. Filtered out rows and rows in collapsed groups do not have visible indexes. The GetVisibleRowCount() method allows you to get the total number of visible rows.

Pass a row visible index to the MakeRowVisible method to make the row visible on screen. Once called, the method performs the following actions:

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

If you pass an invalid visible index, the method does nothing.

In the following code snippet, the Grid component is in vertical virtual scrolling mode. A Scroll to the last row button scrolls the Grid to the last visible row:

razor
@using DxBlazorApplication.Data
@inject WeatherForecastService ForecastService

<DxButton Text="Scroll to the last row" Click="ScrollToLastRow" />
<DxGrid @ref=Grid Data="@forecasts" VirtualScrollingEnabled="true" CssClass="my-class">
    <Columns>
        <DxGridDataColumn FieldName="Date" />
        <DxGridDataColumn FieldName="TemperatureF" />
        <DxGridDataColumn FieldName="Summary" />
    </Columns>
</DxGrid>

@code {
    IGrid Grid;
    private WeatherForecast[]? forecasts;

    void ScrollToLastRow() {
        Grid.MakeRowVisible(Grid.GetVisibleRowCount() - 1);
    }

    protected override async Task OnInitializedAsync() {
        forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
    }
}
css
.my-class {
    height:250px;
}
csharp
namespace DxBlazorApplication.Data {
    public class WeatherForecast {
        public DateTime Date { get; set; }
        public int TemperatureC { get; set; }
        public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
        public string? Summary { get; set; }
    }
}
csharp
namespace DxBlazorApplication.Data {
    public class WeatherForecastService {
        private static readonly string[] Summaries = new[] {
            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
        };

        public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate) {
            var rng = new Random();
            return Task.FromResult(Enumerable.Range(1, 1000).Select(index => new WeatherForecast {
                Date = startDate.AddDays(index),
                TemperatureC = rng.Next(-20, 55),
                Summary = Summaries[rng.Next(Summaries.Length)]
            }).ToArray());
        }
    }
}
csharp
// ...
builder.Services.AddSingleton<WeatherForecastService>();

Implements

MakeRowVisible(Int32)

See Also

MakeCellVisible(Int32, String)

MakeCellVisibleAsync(Object, String)

MakeDataItemVisibleAsync(Object)

DxGrid Class

DxGrid Members

DevExpress.Blazor Namespace