I am using the TelerikAutoComplete component in Blazor with a custom OnRead function to fetch items from a data source. The issue I am facing is:
When I type in the search box, OnRead executes as expected.
But when I erase the search text (set it back to null or empty string), the OnRead function is not triggered.
My expectation is that when the input is cleared, OnRead should fire again so that I can refresh the data (or return an empty dataset).
<TelerikAutoComplete @ref="@autoCompleteRef"
TItem="@AutoCompleteLookupItem"
Id="@Id"
OnRead="@ReadItems"
DebounceDelay="@DebounceTimeMs"
Filterable="@true"
Placeholder="@Placeholder"
FilterOperator="@FilterOperator"
ValueField="@(nameof(AutoCompleteLookupItem.SelectedValue))"
Value="@Value"
ValueExpression="@( () => Value )"
OnChange="HandleValueConfirmation"
ValueChanged="@HandleValueChanged"
Enabled="IsEnabled"
Class="@Class"
OnBlur="@OnFocusLoose">
<ItemTemplate>
@if (!string.IsNullOrWhiteSpace(@context.SelectedValue))
{
@if (context.Hints == null || !context.Hints.Any())
{
//If we do not have any hints. Display only values
@if (context.Value.Key == "--")
{
//Do not display label. Only display value
<span id="value">@context.SelectedValue</span>
}
else
{
//Display both label and value
<span id="label-and-value">@context.Value.Key: @context.SelectedValue</span>
}
}
else if (context.Hints.Count == 1)
{
//If we only have single hint. Display value along with hint.
<span id="value-with-hint">
<strong>@context.SelectedValue</strong>
@if (!string.IsNullOrWhiteSpace(@context.Hints.First().Value))
{
<i> @context.Hints.First().Value</i>
}
</span>
}
else if (context.Hints.Count == 2)
{
@if (string.IsNullOrWhiteSpace(this.Value) || !LookupBehavior.HasFlag(LookupBehavior.HighlightUserInput))
{
<span id="has-empty-value">
<span id="first-hint">@context.Hints.ElementAt(0).Key: @context.Hints.ElementAt(0).Value<br /></span>
<span id="selected-value">@context.Value.Key: @context.SelectedValue <br /></span>
<span id="second-hint">@context.Hints.ElementAt(1).Key: @context.Hints.ElementAt(1).Value</span>
</span>
}
else
{
<span id="has-value">
<span id="first-hint">@context.Hints.ElementAt(0).Key: @UIUtilities.HighlightUserInputWithBoldTags(HttpUtility.HtmlEncode(@context.Hints.ElementAt(0).Value), HttpUtility.HtmlEncode(this.Value)) <br /></span>
<span id="selected-value">@context.Value.Key: @UIUtilities.HighlightUserInputWithBoldTags(HttpUtility.HtmlEncode(@context.SelectedValue), HttpUtility.HtmlEncode(this.Value)) <br /></span>
<span id="second-hint">@context.Hints.ElementAt(1).Key: @UIUtilities.HighlightUserInputWithBoldTags(HttpUtility.HtmlEncode(@context.Hints.ElementAt(1).Value), HttpUtility.HtmlEncode(this.Value))</span>
</span>
}
}
}
</ItemTemplate>
</TelerikAutoComplete>
<div class="icons">
@if (IsEnabled)
{
<span>
<a id="search-link" @onclick="@OpenAutoComplete" title="search">
<svg class="icon" aria-hidden="true" focusable="false">
<use xlink:href="icons/ece-sprite.svg#ece-icon-search"></use>
</svg>
</a>
</span>
}
else
{
<span class="disable-links">
<a id="search-disabled-link">
<svg class="icon" aria-hidden="true" focusable="false">
<use xlink:href="icons/ece-sprite.svg#ece-icon-search"></use>
</svg>
</a>
</span>
}
</div>
</div>
@if (ShowRequiredMessage && !string.IsNullOrWhiteSpace(RequiredMessage))
{
<span id="required-message" class="k-form-error k-invalid-msg ">
@RequiredMessage
</span>
}
@code {
[Parameter]
public string Id { get; set; }
[Parameter]
public string Placeholder { get; set; }
[Parameter]
public EventCallback<string> ValueChanged { get; set; }
[Parameter]
public string BoundField { get; set; }
[Parameter]
public EventCallback<string> ValueConfirmed { get; set; }
[Parameter]
public string Value { get; set; }
[Parameter]
public LookupBehavior LookupBehavior { get; set; } = LookupBehavior.None;
[Parameter]
public int DebounceTimeMs { get; set; } = 500;
[Parameter]
public int InitialSkip { get; set; } = 0;
[Parameter] public Func<string, Task<List<AutoCompleteLookupItem>>> FilterMethod { get; set; }
[Parameter]
public StringFilterOperator FilterOperator { get; set; }
[Parameter]
public string? RequiredMessage { get; set; }
[Parameter]
public bool IsEnabled { get; set; } = true;
[Parameter]
public string Class { get; set; }
public bool ShowRequiredMessage { get; set; }
private List<AutoCompleteLookupItem> dataSource;
private TelerikAutoComplete<AutoCompleteLookupItem> autoCompleteRef { get; set; }
private string lastValue;
private bool lostFocus;
async Task ReadItems(AutoCompleteReadEventArgs args)
{
string userInput = string.Empty;
if (args.Request.Filters.Count > 0)
{
Telerik.DataSource.FilterDescriptor filter = args.Request.Filters[0] as Telerik.DataSource.FilterDescriptor;
userInput = filter.Value.ToString();
}
if (lastValue != userInput)
{
if (!lostFocus)
{
lastValue = userInput;
args.Data = await FilterMethod.Invoke(userInput);
}
else
{
lastValue = this.Value;
args.Data = await FilterMethod.Invoke(lastValue);
lostFocus = false;
}
}
}
private void OnFocusLoose() => lostFocus = true;
private async Task HandleValueConfirmation(object userChoice)
{
string currentValue = (string)userChoice;
if (LookupBehavior.HasFlag(LookupBehavior.TriggerActionOnValueConfirmation))
{
if (currentValue != lastValue)
{
await ValueConfirmed.InvokeAsync((currentValue) ?? string.Empty);
lastValue = currentValue;
}
}
if (LookupBehavior.HasFlag(LookupBehavior.ValidateOnValueConfirmation))
{
if (ValueConfirmed.HasDelegate)
ValueConfirmed.InvokeAsync(BoundField);
ShowRequiredMessage = string.IsNullOrEmpty(this.Value) && !string.IsNullOrEmpty(RequiredMessage);
}
await ValueConfirmed.InvokeAsync((currentValue) ?? string.Empty);
}
async Task OpenAutoComplete()
{
await autoCompleteRef.FocusAsync();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
<!--
Below script is used for opening the autocomplete suggestion upon clicking Search Icon
-->
await js.InvokeVoidAsync("TelerikTweaks.attachFocusHandler", autoCompleteRef.Id, ".k-autocomplete");
}
await base.OnAfterRenderAsync(firstRender);
}
private async Task HandleValueChanged(object newValue)
{
this.Value = (string)newValue;
await ValueChanged.InvokeAsync(this.Value);
}
}
Steps to Reproduce:
Type some text in the autocomplete → OnRead is called ✅.
Erase the text so the input becomes empty (null or "") → OnRead is not called ❌.
Question:
Is this the expected behavior? If so, how can I force the autocomplete to execute OnRead when the input text is cleared (so I can refresh my dataset)?
Do I need to hook into another event (ValueChanged, OnChange, etc.) to manually call ReadItems in this case?

Hello,
I noticed that when TelerikDatePicker and TelerikTimePicker components are used with nullable DateOnly and nullable TimeOnly values, respectively, and ShowClearButton is set to true, the "X" button still appears in an empty field when the value is null. This shouldn’t happen, as there is no value to clear. When you click on the field to type a date or time, the "X" button disappears.
Here is the reproduction of the issue:
https://blazorrepl.telerik.com/GfaCbmlz03hT2mky54
It doesn’t seem like this is intended behavior. If it’s not, is there a workaround to prevent the "X" from appearing when there is no value?
Thanks,
Ivaylo

When a user makes a selection in a dropdown in the first row of a Blazor Grid I want to be able to hide the same column in all the remaining rows to prevent them from making selections in those dropdowns. Is this possible?
I'm getting this error when bound data list for a detail template is null
I don't have a Parameter 'source' in any model so don't understand what this is in reference to?
<DetailTemplate>
<div class="form-group form-inline right">
@{
var bookingEquip = context as BookingEquipmentModel;
<TelerikGrid @ref="@bookingEquipmentCommodityGridRef"
Data="bookingEquip.Commodities"
Pageable="true"
PageSize="4"
Resizable="true"
Size="@ThemeConstants.Grid.Size.Small"
Width="90rem"
EditMode="@GridEditMode.Incell"
OnDelete="@((GridCommandEventArgs args) => OnCommodityDelete(args, bookingEquip))"
OnCreate="@((GridCommandEventArgs args) => OnCommodityCreate(args, bookingEquip))"
OnUpdate="@((GridCommandEventArgs args) => OnCommodityUpdate(bookingEquip, args))">
<GridToolBarTemplate>
<!-- can only add a single commodity if there are none associated with this equipment) -->
<GridCommandButton Command="Add" Class="btn-green" Icon="@FontIcon.Plus" Enabled="@(!bookingEquip.Commodities.Any())">Add Commodity</GridCommandButton>
</GridToolBarTemplate>
<GridColumns>
<!-- Commodity Types -->
<GridColumn Field=@nameof(BookingEquipmentCommodityModel.CommodityType) Editable="true" Title="Description" Width="6rem">
<EditorTemplate Context="cbecContext">
@{
_currentBookingEquipmentCommodityModel = cbecContext as BookingEquipmentCommodityModel;
if (_currentBookingEquipmentCommodityModel != null)
{
<TelerikDropDownList Data="@_CommodityList"
Value="@_currentBookingEquipmentCommodityModel.CommodityTypeId"for the Data reference, bookingEquip is NOT null but it's property bookingEquip.Commodities is indeed null (expected).
The grid displays correctly, but as soon as I click on the "+" expand it will crash with exception in the control.
I'm puzzled as to why this is happening? When I populate other grids (not using a DetailTemplate) in my Blazor app, and the Data reference is a null, nothing is displayed/render in the grid and I just get a "No records available." ... which is good. But the same behavior doesn't seem to happen when using DetailTemplate?
Any suggestions?
Rob.
If I want to restrict the number of selected rows to just three, can I do this with a configuration or a property? I am looking at the following demo. Thanks!

hi,
C:\SQ_AzureDevOps\BlazorApp1\BlazorApp1>dotnet nuget remove source telerik.com
La source de package nommée telerik.com a été correctement supprimée.
C:\SQ_AzureDevOps\BlazorApp1\BlazorApp1>dotnet nuget add source "https://nuget.telerik.com/v3/index.json" --name telerik.com --username "...@..." --password "....." --store-password-in-clear-text
La source de package nommée telerik.com a été correctement ajoutée.
C:\SQ_AzureDevOps\BlazorApp1\BlazorApp1>dotnet add package Telerik.UI.for.Blazor
Générer a réussi dans 0,7s
info : La validation de la chaîne de certificats X.509 utilisera le magasin de confiance par défaut sélectionné par .NET pour le code de signature.
info : La validation de la chaîne de certificats X.509 utilisera le magasin de confiance par défaut sélectionné par .NET pour le timestamp.
info : Ajout de PackageReference pour le package 'Telerik.UI.for.Blazor' dans le projet 'C:\SQ_AzureDevOps\BlazorApp1\BlazorApp1\BlazorApp1.csproj'.
error: Impossible de charger l'index de service pour la source https://nuget.telerik.com/v3/index.json.
error: Response status code does not indicate success: 401 (Unauthorized).
So, its a Trial account nothing wrog with th API-KEY being visible here, but I dont fink I do something wrong, do I?

I am using the TelerikUpload component.
Telerik.UI.for.Blazor version 9.0.0
Extra security checks (anti-virus etc.) are triggered in the Controller and depending on what caused an issue, I would like to change the default "File failed to upload" error message. Ideally this message would be set in the OnError handler, or maybe a ChildTemplate exists I am not aware of?
This post talks about changing the message through localization, but that does not allow me to change it at runtime:

public static List<AggregateFunctionsGroup>? DeserializeGroups<TGroupItem>(this List<AggregateFunctionsGroup> groups)
{
if (groups is null) return null;
for (int i = 0; i < groups.Count; i++)
{
var group = groups[i];
// Workaround for JsonElement -> string
if (group.Key is JsonElement elem && elem.ValueKind == JsonValueKind.String)
{
group.Key = elem.GetString();
}
if (group.HasSubgroups)
{
var subGroups = group.Items
.Cast<JsonElement>()
.Select(x => x.Deserialize<AggregateFunctionsGroup>())
.ToList();
group.Items = DeserializeGroups<TGroupItem>(subGroups);
}
else
{
var items = group.Items
.Cast<JsonElement>()
.Select(x => x.Deserialize<TGroupItem>())
.ToList();
group.Items = items;
}
}
return groups;
}
public async Task ReadItems(GridReadEventArgs args)
{
if (!ModelIsReady) return;
if (_readItemsPending) return;
if (string.IsNullOrWhiteSpace(PreparedQuery.Id)) return;
_readItemsPending = true;
try
{
var result = await ApiService.QueryDataSourceAsync<UniversalDSModel>(PreparedQuery.QueryId, args.Request, CancellationToken.None);
if (result is null) return;
if (args.Request.Groups.Count > 0)
{
args.Data = result?.GroupedData.DeserializeGroups<UniversalDSModel>();
}
else
{
args.Data = result?.CurrentPageData.Cast<object>().ToList();
}
if (result?.AggregateResults != null)
{
args.AggregateResults = result.AggregateResults;
}
if (result != null) { args.Total = result.TotalItemCount; }
}
catch (Exception ex)
{
Console.WriteLine($"Error loading data: {ex.Message}");
ApiRequestFailed = true;
}
finally
{
_readItemsPending = false;
LoaderContainerVisible = false;
}
}
so issue was when i uploading file that still in upload phase if i click the cancel button next upload progress bar the file is removes from ui but somewhere is still present
so i have used OnSelectHandler event to handle to duplicate uploading and some extra validation added in OnSelectHandler event but my issue is
when i am uploading file and immediately click [ Before upload process is done ] cancel then it remove from ui but somewhere is present after that remove click again try to add show my validation error that is duplicate message
Clicking Cancel should stop the upload process entirely, and no file should be uploaded or stored.
Please Refer Below Attachment
Step 1 => Select file eg. dummy.pdf and select Note : AutoUpload is true and check below screenshot and i click cancel button
Step 2 => The file removed from UI see below screenshot
Step 3 => If i try to add again same file i.e dummy.pdf the my custom validation msg show that is file is already present see below screenshot
Below is My Code :