BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
I've created two samples building upon the sample that is provided in the Syncfusion documentation.
The scenario:
@page "/sfautocompletestring"
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.DropDowns
@using SfPlayground.ModelsSfAutoComplete DataSource="_countries"
TItem="Country"
TValue="string">
Value="@nameof(Country.Code)"/> @onclick="OnClick">
Set Belgium
Value: @($"{_value}")
@code
{
private string? _value;
private readonly List_countries = new()
{
new() { Name = "Australia", Code = "AU" },
new() { Name = "Belgium", Code = "BE" },
new() { Name = "Bermuda", Code = "BM" },
new() { Name = "Canada", Code = "CA" },
new() { Name = "Cameroon", Code = "CM" },
new() { Name = "Denmark", Code = "DK" }
};
private void OnClick(MouseEventArgs args)
{
_value = "BE";
}
}
@page "/sfautocomplete"
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.DropDowns
@using SfPlayground.ModelsSfAutoComplete DataSource="_countries"
TItem="Country"
TValue="Country">
Value="@nameof(Country.Code)"/> @onclick="OnClick">
Set Belgium
Value: @($"{_value?.Code}")
@code
{
private Country? _value;
private readonly List_countries = new()
{
new() { Name = "Australia", Code = "AU" },
new() { Name = "Belgium", Code = "BE" },
new() { Name = "Bermuda", Code = "BM" },
new() { Name = "Canada", Code = "CA" },
new() { Name = "Cameroon", Code = "CM" },
new() { Name = "Denmark", Code = "DK" }
};
private void OnClick(MouseEventArgs args)
{
_value = _countries.Find(x => x.Code == "BE");
}
}
We have created a sample based on the shared information and validated the query. Unfortunately, we were unable to replicate the reported issue in your scenario. We also provided a sample for reference. In addition, as mentioned below, we request that you provide additional information about the problem. This will allow us to further investigate the problem and provide you with a prompt solution.
1. Issue reproducing runnable sample (or modify the shared sample as per your scenario).
2. Issue replication steps.
<div class="control"> <p>AutoComplete1 value is: @AutoVal</p><hr /> <SfAutoComplete TValue="string" TItem="Country" Placeholder="e.g. Australia" @bind-Value="@AutoVal" DataSource="@Countries"> <AutoCompleteFieldSettings Text="Name" Value="Code"></AutoCompleteFieldSettings> </SfAutoComplete> <hr />
@if(AutoVal1 != null) { <p>AutoComplete2 value is: @AutoVal1.Code</p> } <hr /> <SfAutoComplete TValue="Country" TItem="Country" Placeholder="e.g. Australia" @bind-Value="AutoVal1" DataSource="@Countries"> <AutoCompleteFieldSettings Text="Name" Value="Code"></AutoCompleteFieldSettings> </SfAutoComplete>
<hr> <SfButton OnClick="updatevalue" Content="Update"></SfButton> </div> @code { public string AutoVal { get; set; } public Country? AutoVal1 { get; set; } = new Country() { };
public class Country { public string Name { get; set; }
public string Code { get; set; } }
void updatevalue() { AutoVal = "BM"; // TValue="string" AutoVal1 = new Country() { Name = "Bermuda", Code = "BM" }; // TValue="Country" } } |
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/AutoComplete_Blazor1609010545
Hi,
For some reason the formatting of the code block broke the actual code snippet.
Please find a sample application attached. The reproductions steps are described in the original post and displayed in the screen capture.
Kind regards,
Niels
On our end, the reported issue “preselect value does not update to the component when the TValue and TItem provided as ValueTuple type” has already been resolved in the 20.2.39 version. To resolve the current issue, please upgrade your NuGet to the most recent version.
Release Notes : https://blazor.syncfusion.com/documentation/release-notes/20.2.39?type=all#dropdownlist
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/SfAutoCompleteSample1606933507