-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathIndex.razor
52 lines (50 loc) · 2.11 KB
/
Index.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@page "/"
@using GridExportingWithReports.Data
@using System;
@using System.Threading
@using System.Threading.Tasks
@using DevExtreme.AspNet.Data.ResponseModel
@using DevExtreme.AspNet.Data
@using System.Collections.ObjectModel
@inject WeatherForecastService WeatherForecastService
@inject NavigationManager NavigationManager
@inject IJSRuntime JsRuntime;
@if (forecasts != null) {
<DxGrid Data="@Data"
PageSize="5" ShowFilterRow="true">
<Columns>
<DxGridDataColumn FieldName="@nameof(WeatherForecast.TemperatureC)" Caption="Temp. (C)" />
<DxGridDataColumn FieldName="@nameof(WeatherForecast.TemperatureF)" Caption="Temp. (F)" />
<DxGridDataColumn FieldName="@nameof(WeatherForecast.Summary)" Caption="Summary" />
<DxGridDataColumn FieldName="@nameof(WeatherForecast.Date)" DisplayFormat="D" />
</Columns>
</DxGrid>
<p></p>
<ExportButtons ExportUrlInfo="@exportUrlInfo"></ExportButtons>
}
else {
<span>Loading...</span>
}
@code {
private readonly ObservableCollection<Tuple<string, string>> exportUrlInfo = new ObservableCollection<Tuple<string, string>>();
object Data { get; set; }
WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await WeatherForecastService.GetForecastAsync();
var dataSource = new GridDevExtremeDataSource<WeatherForecast>(forecasts.AsQueryable<WeatherForecast>());
dataSource.CustomizeLoadOptions = (loadOptions) =>
{
if (loadOptions.IsCountQuery == false)
{
string baseUri = NavigationManager.BaseUri.ToString();
exportUrlInfo.Clear();
exportUrlInfo.Add(Tuple.Create(loadOptions.ConvertToGetRequestUri(baseUri + "exportPdf"), "Export PDF"));
exportUrlInfo.Add(Tuple.Create(loadOptions.ConvertToGetRequestUri(baseUri + "exportXlsx"), "Export XLSX"));
exportUrlInfo.Add(Tuple.Create(loadOptions.ConvertToGetRequestUri(baseUri + "exportDocx"), "Export DOCX"));
}
var t = 0;
};
Data = dataSource;
}
}