Thanks for sharing the details.
From your query we understand that you are facing issue while binding the datasource in form of IEnumerable of some interface. We do not have support for direct interface binding support, as model type is required for various operations like column field mapping, validation and model instance creation during editing/adding. So we suggest you to bind the data by using a specific model type which inherits the interface.
For your convenience we have prepared a sample using interface and specific model to bind data to Grid and perform Data Operation. Refer the below code example.
|
@inject IOrderService OrderService
<SfGrid DataSource="@Orders" AllowFiltering="true" AllowPaging="true" Height="315">
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
. . . . . .
</SfGrid>
@code{
public IEnumerable<Order> Orders { get; set; }
protected override async Task OnInitializedAsync()
{
Orders = await OrderService.GetEmployees();
}
}
public class OrderService : IOrderService { public async Task<IEnumerable<Order>> GetEmployees() { IEnumerable<Order> employees; employees = Enumerable.Range(1, 75).Select(x => new Order() { OrderID = 1000 + x, CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)], Freight = 2.1 * x, OrderDate = (new DateTime[] { new DateTime(2010, 5, 1), new DateTime(2010, 5, 2), new DateTime(2010, 5, 3), })[new Random().Next(3)], }).ToList(); return employees; } }public interface IOrderService { Task<IEnumerable<Order>> GetEmployees(); }
|
Kindly download the sample from below
Please get back to us if you have further queries.
Regards,
Vignesh Natarajan