Have a simple API that is taking about 30seconds to complete. When it completes, the datagrid never renders but if i reduce the no of records the APi returns, then it renders? How do manage large running queries?
Using client side
protected override async Task OnInitializedAsync()
{
//Reservations = await Http.GetFromJsonAsync<List<AccountBalance>>($"http://localhost:18417/balance?skeyword=cat");
using (var httpClient = new HttpClient())
{
using (var response = await httpClient.GetAsync("http://localhost:18417/balance?skeyword=gold"))
{
string apiResponse = await response.Content.ReadAsStringAsync();
Reservations = JsonConvert.DeserializeObject<IEnumerable<AccountBalance>>(apiResponse);
}
}
StateHasChanged();
}
Hi Anthony,
Greetings from Syncfusion.
We have checked your query with the provided details. We have get the data using GetFromJsonAsync and bind it to the Grid based on your case. We could not face the reported problem(grid does not render after fetching data). Find the below code snippets and sample for your reference.
Also, we suspect that the data fetching operation might be delay from your end. So for this scenario, we suggest you to show the Grid after the data is fetched from your service like below.
|
@inject HttpClient Http
@if (forecasts != null) //render the Grid while the data is available { <SfGrid DataSource="forecasts" AllowPaging="true" @ref="dataGrid"> <GridColumns> <GridColumn Field="@nameof(WeatherForecast.Id)" IsPrimaryKey="true"></GridColumn> <GridColumn Field="@nameof(WeatherForecast.Date)" HeaderText="Date"></GridColumn> <GridColumn Field="@nameof(WeatherForecast.Summary)" HeaderText="Summary"></GridColumn> <GridColumn Field="@nameof(WeatherForecast.TemperatureF)" HeaderText="F"></GridColumn> </GridColumns> </SfGrid> } else { <p>Loading...Fetching Data...</p> }
@code {
SfGrid<WeatherForecast> dataGrid; private WeatherForecast[] forecasts;
protected override async Task OnInitializedAsync() { forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast"); } } |
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Grid2035623484
If you are still facing the problem, then could you please share the below details? It will be helpful to validate and provide a better solution.
Regards,
Rahul