DevExpress v24.2 Update — Your Feedback Matters
Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.
Take the survey
Not interested
DxGrid.WaitForRemoteSourceRowLoadAsync(Int32) Method
Returns a task that is completed when the specified row of an asynchronous remote data source is loaded.
Namespace : DevExpress.Blazor
Assembly :
DevExpress.Blazor.v24.2.dll
NuGet Package :
DevExpress.Blazor
# Declaration
C#
public Task WaitForRemoteSourceRowLoadAsync (
int visibleIndex
)
# Parameters
# Returns
Type
Description
Task
The task that is completed when the row is loaded.
The following data sources are designed to work with large data collections:
They load data asynchronously in small portions on demand (instead of the entire dataset).
Call the WaitForRemoteSourceRowLoadAsync
method to ensure that the specified data row is loaded. For instance, call this method before those that accept a row’s visible index as a parameter (SelectRow , StartEditRowAsync , and so on).
For multiple rows, use the await Task.WhenAll(…) statement to combine multiple WaitForRemoteSourceRowLoadAsync
method calls.
The following example selects a row that is outside the visible range and not yet loaded:
@using Microsoft.EntityFrameworkCore
@using DevExpress.Data.Linq
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@ implements IDisposable
<DxGrid Data ="InstantFeedbackSource"
AllowSelectRowByClick ="true"
KeyFieldName ="OrderId"
@ref ="MyGrid" >
<Columns >
<DxGridDataColumn FieldName ="ShipName" />
<DxGridDataColumn FieldName ="ShipCity" />
<DxGridDataColumn FieldName ="ShipCountry" />
<DxGridDataColumn FieldName ="Freight" />
<DxGridDataColumn FieldName ="OrderDate" />
<DxGridDataColumn FieldName ="ShippedDate" />
</Columns >
</DxGrid >
<DxButton Click ="OnSelectRow" > Select Row 100</DxButton >
@ code {
EntityInstantFeedbackSource InstantFeedbackSource { get ; set ; }
NorthwindContext Northwind { get ; set ; }
IGrid MyGrid { get ; set ; }
protected override void OnInitialized ( ) {
Northwind = NorthwindContextFactory.CreateDbContext();
InstantFeedbackSource = new EntityInstantFeedbackSource(e => {
e.KeyExpression = "OrderId" ;
e.QueryableSource = Northwind.Orders;
});
}
public async Task OnSelectRow ( ) {
await MyGrid.WaitForRemoteSourceRowLoadAsync(100 );
MyGrid.SelectRow(100 );
}
public void Dispose ( ) {
InstantFeedbackSource?.Dispose();
Northwind?.Dispose();
}
}
using System ;
using System.Collections.Generic ;
#nullable disable
namespace Grid.Northwind {
public partial class Order {
public Order ( ) {
OrderDetails = new HashSet<OrderDetail>();
}
public int OrderId { get ; set ; }
public string CustomerId { get ; set ; }
public int ? EmployeeId { get ; set ; }
public DateTime? OrderDate { get ; set ; }
public DateTime? RequiredDate { get ; set ; }
public DateTime? ShippedDate { get ; set ; }
public int ? ShipVia { get ; set ; }
public decimal ? Freight { get ; set ; }
public string ShipName { get ; set ; }
public string ShipAddress { get ; set ; }
public string ShipCity { get ; set ; }
public string ShipRegion { get ; set ; }
public string ShipPostalCode { get ; set ; }
public string ShipCountry { get ; set ; }
public virtual Customer Customer { get ; set ; }
public virtual Shipper ShipViaNavigation { get ; set ; }
public virtual ICollection<OrderDetail> OrderDetails { get ; set ; }
}
}
using Microsoft.EntityFrameworkCore ;
#nullable disable
namespace Grid.Northwind {
public partial class NorthwindContext : DbContext {
public NorthwindContext (DbContextOptions<NorthwindContext> options )
: base (options ) {
}
public virtual DbSet<Order> Orders { get ; set ; }
protected override void OnConfiguring (DbContextOptionsBuilder optionsBuilder ) {
if (!optionsBuilder.IsConfigured) {
optionsBuilder.UseSqlServer("Server=.\\sqlexpress;Database=Northwind;Integrated Security=true" );
}
}
protected override void OnModelCreating (ModelBuilder modelBuilder ) {
modelBuilder.HasAnnotation("Relational:Collation" , "SQL_Latin1_General_CP1_CI_AS" );
modelBuilder.Entity<Order>(entity => {
entity.HasIndex(e => e.CustomerId, "CustomerID" );
entity.HasIndex(e => e.CustomerId, "CustomersOrders" );
entity.HasIndex(e => e.EmployeeId, "EmployeeID" );
entity.HasIndex(e => e.EmployeeId, "EmployeesOrders" );
entity.HasIndex(e => e.OrderDate, "OrderDate" );
entity.HasIndex(e => e.ShipPostalCode, "ShipPostalCode" );
entity.HasIndex(e => e.ShippedDate, "ShippedDate" );
entity.HasIndex(e => e.ShipVia, "ShippersOrders" );
entity.Property(e => e.OrderId).HasColumnName("OrderID" );
entity.Property(e => e.CustomerId)
.HasMaxLength(5 )
.HasColumnName("CustomerID" )
.IsFixedLength(true );
entity.Property(e => e.EmployeeId).HasColumnName("EmployeeID" );
entity.Property(e => e.Freight)
.HasColumnType("money" )
.HasDefaultValueSql("((0))" );
entity.Property(e => e.OrderDate).HasColumnType("datetime" );
entity.Property(e => e.RequiredDate).HasColumnType("datetime" );
entity.Property(e => e.ShipAddress).HasMaxLength(60 );
entity.Property(e => e.ShipCity).HasMaxLength(15 );
entity.Property(e => e.ShipCountry).HasMaxLength(15 );
entity.Property(e => e.ShipName).HasMaxLength(40 );
entity.Property(e => e.ShipPostalCode).HasMaxLength(10 );
entity.Property(e => e.ShipRegion).HasMaxLength(15 );
entity.Property(e => e.ShippedDate).HasColumnType("datetime" );
entity.HasOne(d => d.Customer)
.WithMany(p => p.Orders)
.HasForeignKey(d => d.CustomerId)
.HasConstraintName("FK_Orders_Customers" );
entity.HasOne(d => d.ShipViaNavigation)
.WithMany(p => p.Orders)
.HasForeignKey(d => d.ShipVia)
.HasConstraintName("FK_Orders_Shippers" );
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial (ModelBuilder modelBuilder ) ;
}
}
using Microsoft.EntityFrameworkCore ;
builder.Services.AddDbContextFactory<NorthwindContext>((sp, options) => {
var env = sp.GetRequiredService<IWebHostEnvironment>();
var dbPath = Path.Combine(env.ContentRootPath, "Northwind-5e44b51f.mdf" );
options.UseSqlServer("Server=(localdb)\\MSSQLLocalDB;Integrated Security=true;AttachDbFileName=" + dbPath);
});
See Also