Back to Devexpress

DxGrid.ShowAllRowsChanged Event

blazor-devexpress-dot-blazor-dot-dxgrid-342f435d.md

latest4.1 KB
Original Source

DxGrid.ShowAllRowsChanged Event

Fires when the ShowAllRows property value changes.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public EventCallback<bool> ShowAllRowsChanged { get; set; }

Parameters

TypeDescription
Boolean

The new ShowAllRows property value.

|

Remarks

Enable the ShowAllRows option to display all Grid rows on one page. Note that if the Grid contains a large amount of data rows, this option can affect Grid performance.

Handle the ShowAllRowsChanged event to react when the ShowAllRows property value changes.

razor
@inject WeatherForecastService ForecastService

<DxGrid Data="@Data" 
        ShowAllRowsChanged=@OnShowAllRowsChanged
        PageSizeSelectorVisible="true"
        PageSizeSelectorAllRowsItemVisible="true"
        PageSizeSelectorItems="@(new int[] {3,4,5})"
        @bind-PageSize=@PageSize>
    <Columns>
        <DxGridDataColumn FieldName="Date" />
        <DxGridDataColumn FieldName="TemperatureC" />
        <DxGridDataColumn FieldName="TemperatureF" />
    </Columns>
</DxGrid>

@Message

@code {
    object Data { get; set; }
    string Message { get; set; }
    int PageSize = 3;
    void OnShowAllRowsChanged(bool AllRows) {
        if (AllRows)
            Message = "All rows are visible";
        else
            Message = PageSize + " rows are visible";
    }

    protected override void OnInitialized() {
        Data = ForecastService.GetForecast();
    }
}
csharp
using System;

public class WeatherForecast {
    public DateTime Date { get; set; }
    public int TemperatureC { get; set; }
    public double TemperatureF => Math.Round((TemperatureC * 1.8 + 32), 2);
    public string Forecast { get; set; }
    public string CloudCover { get; set; }
    public bool Precipitation { get; set; }
}
csharp
using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading;
    using System.Threading.Tasks;

    public class WeatherForecastService {
        private List<WeatherForecast> Forecast { get; set; }

        private static string[] CloudCover = new[] {
            "Sunny", "Partly cloudy", "Cloudy", "Storm"
        };

        Tuple<int, string>[] ConditionsForForecast = new Tuple<int, string>[] {
            Tuple.Create( 22 , "Hot"),
            Tuple.Create( 13 , "Warm"),
            Tuple.Create( 0 , "Cold"),
            Tuple.Create( -10 , "Freezing")
        };

        public WeatherForecastService() {
            Forecast = CreateForecast();
        }

        private List<WeatherForecast> CreateForecast() {
            var rng = new Random();
            DateTime startDate = DateTime.Now;
            return Enumerable.Range(1, 15).Select(index => {
                var temperatureC = rng.Next(-10, 30);
                return new WeatherForecast {
                    Date = startDate.AddDays(index),               
                    TemperatureC = temperatureC,
                    CloudCover = CloudCover[rng.Next(0, 4)],
                    Precipitation = Convert.ToBoolean(rng.Next(0, 2)),
                    Forecast = ConditionsForForecast.First(c => c.Item1 <= temperatureC).Item2
                };
            }).ToList();
        }

        public IEnumerable<WeatherForecast> GetForecast() {
            return Forecast.ToArray();
        }
        // ...
}
csharp
// ...
builder.Services.AddSingleton<WeatherForecastService>();

See Also

DxGrid Class

DxGrid Members

DevExpress.Blazor Namespace