I have a SQL Server database with a regular restful API. I need to use the Autocomplete with Virtualization to retrieve the data. I tried implementing the sample code from your documentation, and in one case, I was able to get a valid response from the API, but I could not get the data to show up in the control. I tried googling and using Copilot and ChatGpt, and neither of those were helpful.
[Route("api/[controller]")]
[ApiController]
public class QuestionController : ControllerBase
{
private readonly ApplicationDbContext _context;
private readonly IMapper _mapper;
public QuestionController(ApplicationDbContext context, IMapper mapper)
{
_context = context;
_mapper = mapper;
}
// GET: api/Question
[HttpPost("GetQuestionsContainingQuestionText")]
public async Task<ActionResult<IEnumerable<QuestionViewModel>>> GetQuestionsContainingQuestionText()
{
List<Question> questions = await _context.Questions.ToListAsync();
return Ok(_mapper.Map<IEnumerable<QuestionViewModel>>(questions));
}
How can I call this api with virtualization enabled, and show the results in the autocomplete?
Hi David,
Thank you for reaching out to us. We understand you're trying to integrate the AutoComplete component with virtualization enabled, using data retrieved from your SQL Server database via a RESTful API.
Based on the code snippet you shared, the API seems to be working correctly and returning the expected data. However, to use virtualization with our AutoComplete component, there are a few additional steps needed to ensure data is fetched and bound properly using server-side operations like skip and take.
To assist you further, we recommend referring to the following resources that demonstrate how to correctly configure the component with a WebApiAdaptor and handle server-side paging:
https://blazor.syncfusion.com/documentation/datagrid/data-binding#web-api
https://blazor.syncfusion.com/documentation/autocomplete/data-binding#web-api-adaptor
If you’re still facing issues after following the examples, we kindly request you to share a runnable sample or a screen recording showing the issue. This will help us provide a more accurate solution tailored to your setup.
Please let us know if you have any further questions
Regards,
Yohapuja S
Thanks for your reply. In the end, I added an Odata controller and got it working. Feel free to consider this as resolved.
Thanks,
David
Hi David Warwick,
Glad to know your issue has been resolved. Please get back to us for assistance in the future.
Regards,
Shereen