I developed a CustomAdaptor to feed a SfGrid . The adaptor is pull IEnumerable data from web API using httpclient.
The ReadAsync method is successfull. but when the data gets to the SfGrid control, it generates an error saying
SfGrid`1.<DataProcess>d__458.MoveNext(). With the codes below, I would be grateful if someone helps me to solve the issue
-------------------------------------------------------------------------------------------------------------------------------
[HttpGet("GetAllCtorRecords")]
public IActionResult GetAllCtors()
{
List<SampleCtor> datasource = dbContext.SampleCtors.ToList();
var count = datasource.Count();
return Ok(datasource);
}
---------------------------------------------------------------------------------------------------------------------------
<SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>
public override async Task<object> ReadAsync(DataManagerRequest dm, string key = null)
{
try
{
IEnumerable<SampleCtor> datasource = null;
datasource = await this.apiService.Client
.GetFromJsonAsync<IEnumerable<SampleCtor>>("/api/SampleCtor/GetAllCtorRecords");
var count = datasource.Count();
datasource = DataOperations.Execute(datasource, dm);
return Task.FromResult(dm.RequiresCounts ? new DataResult() { Result = datasource, Count = count } : (object)datasource);
}
catch (Exception ex)
{
return base.ReadAsync(dm, key);
}
}
Hi Frederick,
Greetings from Syncfusion support.
Query: “I developed a CustomAdaptor to feed a SfGrid . The adaptor is pull IEnumerable data from web API using httpclient. The ReadAsync method is successfull. but when the data gets to the SfGrid control, it generates an error”
We have checked your query and prepared an sample as per your shared reference. But we could able to reproduce the reported issue at our end. Kindly refer the below sample and code example for your reference
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/APIService13663820.zip
Note: Kindly change the connection string in OrderContext.cs file based on Northwnd.MDF file in App_data folder
|
[CustomAdaptor.razor] // Performs data Read operation public override async Task<object> ReadAsync(DataManagerRequest dm, string key = null) { var data = await Service.GetPeople(dm); IEnumerable<Order> DataSource = data.result; int count = data.count; return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource; }
|
Refer the below ug documentation for your reference
https://blazor.syncfusion.com/documentation/datagrid/custom-binding#custom-adaptor-as-component
If the reported issue still reproduced then kindly share the below details to validate further at our end.
The above-requested details will be very helpful for us to validate the reported query at our end and provide the solution as early as possible.
Regards,
Monisha