-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataProperty.razor
More file actions
36 lines (29 loc) · 1.74 KB
/
DataProperty.razor
File metadata and controls
36 lines (29 loc) · 1.74 KB
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
@page "/DataProperty"
@inject WeatherForecastService WeatherForecastService
<h2>Data Property</h2>
<p>
This example uses the <a class="helplink" href="https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxDataGrid-1.Data" target="_blank">Data</a> property to bind the Data Grid to a strongly typed collection. An asynchronous task initializes this collection in the <a class="helplink" href="https://docs.microsoft.com/en-us/aspnet/core/blazor/components/lifecycle#component-initialization-methods" target="_blank">OnInitializedAsync</a> lifecycle method. Note that the <b>Render GUID</b> changes during page initialization. This means that the page is rendered twice: before the task is completed (field values are not initialized) and after the task is completed (the task initialized field values).
</p>
<p>
<b>Render GUID</b>: @Guid.NewGuid()
</p>
<p>
To prevent excessive re-rendering for Data Grid pages, use the <a class="helplink" href="https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxDataGrid-1.DataAsync" target="_blank">DataAsync</a> property demonstrated on the remaining pages.
</p>
@if (DataSource != null) {
<DxDataGrid Data="@DataSource">
<Columns>
<DxDataGridColumn Field="@nameof(WeatherForecast.Summary)" />
<DxDataGridDateEditColumn Field="@nameof(WeatherForecast.Date)" />
<DxDataGridSpinEditColumn Field="@nameof(WeatherForecast.TemperatureC)" />
<DxDataGridSpinEditColumn Field="@nameof(WeatherForecast.TemperatureF)" />
</Columns>
@*...*@
</DxDataGrid>
}
@code {
WeatherForecast[] DataSource;
protected override async Task OnInitializedAsync() {
DataSource = await WeatherForecastService.GetForecastAsync(DateTime.Now.Date);
}
}