<SfGrid TValue="Order" ID="Grid" AllowSorting="true" AllowFiltering="true" AllowPaging="true">
<SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>
..
..
</SfGrid>
@code {
private WeatherForecast[] Orders;
protected override async Task OnInitializedAsync()
{
//Save the whole data from the Server locally and process action with this data
Orders = await ForecastService.GetForecastAsync(DateTime.Now);
}
public class CustomAdaptor : DataAdaptor
{
// Performs data Read operation
public override object Read(DataManagerRequest dm, string key = null)
{
IEnumerable<Order> DataSource = Orders;
..
..
..
return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource;
}
|
public class CustomAdaptor : DataAdaptor
{
// Performs data Read operation
public override object Read(DataManagerRequest dm, string key = null)
{
IEnumerable<Order> DataSource = Orders;
int count = DataSource.Cast<Order>().Count();
// Handle data operations here based on your requirement
if (dm.Skip != 0 || dm.Take != 0)
{
//Paging Locally
DataSource = Orders.Skip(dm.Skip).Take(dm.Take);
}
return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource;
}
} |