Load data when visible

1 Answer 9 Views
Carousel
Nicholas
Top achievements
Rank 1
Nicholas asked on 27 Aug 2025, 10:30 AM

Hi,

I'm using the carousel as a rotating dashboard.

Is it possible to only load the data when the controls become visible, and not all when the page loads.

Thanks

Nick

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 29 Aug 2025, 03:13 PM

Hi Nick,

You can load the data for the Carousel only after it becomes visible by using the Blazor component lifecycle methods. The recommended approach is to use the OnAfterRenderAsync method, which lets you trigger data loading after all components on the page have finished rendering. This ensures that the data is loaded only when the Carousel is actually visible to the user.

Example: Load data after the Carousel is rendered

protected override async Task OnAfterRenderAsync(bool firstRender)
{
    if (firstRender)
    {
        // Load data when the Carousel becomes visible
        await Task.Delay(500); // Optional delay if needed
        CarouselData = await LoadCarouselDataAsync();
        StateHasChanged(); // Update the UI with the loaded data
    }
}
Example:
https://blazorrepl.telerik.com/mJuWcDFf119ymnki26

 

    Regards,
    Ivan Danchev
    Progress Telerik

    Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

    Tags
    Carousel
    Asked by
    Nicholas
    Top achievements
    Rank 1
    Answers by
    Ivan Danchev
    Telerik team
    Share this question
    or