Skip to content

Add new kb article combobox-virtualization-loader #3123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

georgedautov
Copy link
Contributor

No description provided.

@georgedautov georgedautov requested a review from a team as a code owner July 21, 2025 14:21
@georgedautov georgedautov requested a review from yanisslav July 21, 2025 14:21
@georgedautov georgedautov force-pushed the combobox-loader-kb-example branch from cf23fe7 to f1d3623 Compare July 29, 2025 07:42
page_title: Adding Loader to ComboBox During Remote Data Fetch and Virtualization
slug: adding-loader-combobox-remote-data-virtualization
position:
tags: combobox, ui-for-blazor, templates, nodatatemplate, header-template, loader
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tags: combobox, ui-for-blazor, templates, nodatatemplate, header-template, loader
tags: blazor, combobox, loader, templates, nodatatemplate, headertemplate

@@ -0,0 +1,159 @@
---
title: Displaying Loading Indicator in ComboBox with Remote Data and Virtualization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People are more likely to google without -ing.

Suggested change
title: Displaying Loading Indicator in ComboBox with Remote Data and Virtualization
title: Display Loading Indicator in ComboBox with Remote Data and Virtualization

description: Learn how to add a loading indicator in the TelerikComboBox component when using remote data and virtualization functionality in UI for Blazor.
type: how-to
page_title: Adding Loader to ComboBox During Remote Data Fetch and Virtualization
slug: adding-loader-combobox-remote-data-virtualization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming convention is:

componentname-kb-foo-bar

Usually, the .md file name is the same, but without the -kb part

Comment on lines +151 to +150
### Key Points
- Use the `HeaderTemplate` for displaying a loading indicator during scrolling or filtering.
- Call the `Refresh` method on the ComboBox reference to update the UI dynamically during data load operations.
- Toggle visibility of old items using CSS to enhance user experience.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be merged with the solution above.

Comment on lines 32 to 34
### 1. Display a Loading Indicator During Remote Data Fetch
Use the `HeaderTemplate` property of the ComboBox component to show a loading indicator. Add a boolean flag to track the loading state and update it dynamically during data fetch operations. Use a CSS rule to disable the default "No Data" message.

### 2. Clear Old Items During Filtering/Search
Modify the visibility of old items using CSS rules and conditionally toggle their appearance based on the loading state.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use a numbered list for the steps:
https://www.telerik.com/blazor-ui/documentation/knowledge-base/grid-search-button-click

Headings are acceptable if you want to show two alternative ways to achieve the same result, with two separate examples:
https://www.telerik.com/blazor-ui/documentation/knowledge-base/grid-get-filtered-data#solution

Comment on lines 38 to 40
### Implementation

Below is an example implementation that solves both issues:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the above comment, this part is probably unnecessary. Add a caption> before the example though.

Comment on lines +136 to +138
// used to showcase how you could simplify the return of more than one value from the service
public class DataEnvelope<T>
{
public int Total { get; set; }
public List<T> Data { get; set; }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part adds an unnecessary and irrelevant complication. Use a simpler example without it.
https://www.telerik.com/blazor-ui/documentation/components/multicolumncombobox/virtualization#remote-data-example


public static async Task<DataEnvelope<Person>> GetItems(DataSourceRequest request)
{
await Task.Delay(3000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This delay is too long and the example UX is bad. For example, the ComboBox remains empty for some time, even though it's evident that it has a Value.

Suggested change
await Task.Delay(3000);
await Task.Delay(500);

Comment on lines 128 to 130
public static async Task<Person> GetItemFromValue(int selectedValue)
{
await Task.Delay(400); // simulate real network and database delays. Remove in a real app

return await Task.FromResult(AllData.FirstOrDefault(x => selectedValue == x.Id));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Task.FromResult is some weird approach that we have in very old examples, but it's completely unnecessary.

Suggested change
public static async Task<Person> GetItemFromValue(int selectedValue)
{
await Task.Delay(400); // simulate real network and database delays. Remove in a real app
return await Task.FromResult(AllData.FirstOrDefault(x => selectedValue == x.Id));
}
}
public static async Task<Person?> GetItemFromValue(int selectedValue)
{
await Task.Delay(400); // simulate real network and database delays. Remove in a real app
return AllData.FirstOrDefault(x => selectedValue == x.Id);
}

Total = result.Total
};

return await Task.FromResult(dataToReturn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return await Task.FromResult(dataToReturn);
return dataToReturn;

ComboBoxRef?.Refresh();
}

async Task<Person> GetModelFromValue(int selectedValue)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoids a compiler warning

Suggested change
async Task<Person> GetModelFromValue(int selectedValue)
async Task<Person?> GetModelFromValue(int selectedValue)

@georgedautov georgedautov force-pushed the combobox-loader-kb-example branch from f1d3623 to fa6a7ad Compare August 4, 2025 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants