Using AutoComplete with Virtualization to Get Data from Non-OData API

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?


3 Replies 1 reply marked as answer

YS Yohapuja Selvakumaran Syncfusion Team April 9, 2025 05:23 AM UTC

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://www.syncfusion.com/forums/175214/how-to-pass-the-current-page-information-skip-and-take-when-remove-is-called

https://www.syncfusion.com/forums/164461/asp-net-core-backend-implementation-for-webapiadaptor-not-urladaptor

https://www.syncfusion.com/forums/190964/server-side-pagination-pager-on-client-side-shows-only-the-first-page

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


Marked as answer

DW David Warwick April 9, 2025 05:51 PM UTC

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 



SS Shereen Shajahan Syncfusion Team April 10, 2025 04:41 AM UTC

Hi David Warwick,

Glad to know your issue has been resolved. Please get back to us for assistance in the future.

Regards,

Shereen


Loader.
Up arrow icon