blazor-devexpress-dot-blazor-dot-dxtreelist-dot-waitforremotesourcerowloadasync-x28-system-dot-int32-x29.md
Returns a task that is completed when the specified row of a remote data source is loaded.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
public Task WaitForRemoteSourceRowLoadAsync(
int visibleIndex
)
| Name | Type | Description |
|---|---|---|
| visibleIndex | Int32 |
The row’s visible index.
|
| Type | Description |
|---|---|
| Task |
The task that is completed when the row is loaded.
|
Call the WaitForRemoteSourceRowLoadAsync method to ensure the specified data row is loaded when the TreeList is bound to the GridDevExtremeDataSource, Custom Data Source, or loads data on demand. For instance, call this method before methods that accept a row’s visible index as a parameter (SelectRow, ExpandRow, and so on).
For multiple rows, use the await Task.WhenAll(…) statement to combine multiple WaitForInstantFeedbackRowLoadAsync method calls.
The following example focuses a row that is outside the visible range:
@inject CitiesService CitiesService
<DxTreeList @ref="MyTreeList"
Data="@Data"
FocusedRowEnabled="true"
KeyFieldName="ID"
ParentKeyFieldName="ParentID"
HasChildrenFieldName="HasChildren">
<Columns>
<DxTreeListDataColumn Caption="Location" FieldName="Name" />
<DxTreeListDataColumn FieldName="CityType" />
<DxTreeListDataColumn FieldName="Year" DisplayFormat="d"/>
<DxTreeListDataColumn FieldName="RecordType" />
<DxTreeListDataColumn FieldName="Population" />
</Columns>
</DxTreeList>
<DxButton Click="OnFocusRow">Focus the 100th Row</DxButton>
@code {
ITreeList MyTreeList { get; set; }
object Data { get; set; }
protected override async Task OnInitializedAsync() {
var cities = await CitiesService.GetCitiesAsync();
Data = new GridDevExtremeDataSource<Location>(cities.AsQueryable());
}
public async Task OnSelectRow() {
await MyTreeList.WaitForRemoteSourceRowLoadAsync(99);
MyTreeList.SetFocusedRowIndex(99);
}
}
public class Location {
public string? Name { get; set; }
public string? City { get; set; }
public string? Country { get; set; }
public decimal Population { get; set; }
public int ID { get; set; }
public int ParentID { get; set; }
public string? CityType { get; set; }
public string? RecordType { get; set; }
public int? Year { get; set; }
public bool HasChildren { get; set; }
}
public class CitiesService {
CitiesContext _context;
public CitiesService(IDbContextFactory<CitiesContext> contextFactory) {
_context = contextFactory.CreateDbContext();
}
public void SeedData() {
_context.Database.EnsureCreated();
if (_context.Locations.Any())
return;
var stream = File.OpenRead(@"cities.json");
var cities = System.Text.Json.JsonSerializer.Deserialize<Location[]>(stream);
if (cities == null)
return;
foreach (var city in cities) {
city.ID++;
city.ParentID++;
}
_context.Locations.AddRange(cities);
_context.SaveChanges();
}
public async Task<Location[]?> GetCitiesAsync() {
await _context.Locations.LoadAsync();
return _context.Locations.Local.ToArray();
}
}
WaitForRemoteSourceRowLoadAsync(Int32)
WaitForRemoteSourceRowLoadAsync(Int32)
See Also