Hi Martin,
We can directly given the required value which is needs to be displayed in the component with help of using bind-value attribute. We have prepared the sample by setting the initial value in the web API adaptor and attached it below,
Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/WASM_1628471732601409Regards,Berly B.C
|
@page "/"
@inject IJSRuntime JSRuntime;
@using ClientHost.Data
@using Syncfusion.Blazor
@using Syncfusion.Blazor.DropDowns
@using Syncfusion.Blazor.Data
<SfAutoComplete @ref="AutoObj" TValue="int" TItem="Orders" Placeholder="Select a Employee" AllowFiltering="true" @bind-Value="@AutoVal">
<SfDataManager Url="api/Default" Adaptor="Adaptors.WebApiAdaptor" CrossDomain="true">
</SfDataManager>
<AutoCompleteFieldSettings Value="OrderID" Text="CustomerID" />
<AutoCompleteEvents TValue="int" TItem="Orders" Filtering="onFiltering"></AutoCompleteEvents>
</SfAutoComplete>
@code{
SfAutoComplete<int, Orders> AutoObj;
public Query Query = new Query();
public int AutoVal { get; set; } = 2;
public void onFiltering(FilteringEventArgs args)
{
args.PreventDefaultAction = true;
Query = new Query().Where(new WhereFilter()
{
Field = "CustomerID",
value = args.Text,
Operator = "startswith",
IgnoreCase = true
}).Take(10);
this.AutoObj.Filter(null, Query);
}
} |
Hi Martin,
We would like to inform you that, the AutoComplete component filters the value based on the value mapped in the Value field. Due to this, you have received the OrderID as a filtering field in the controller since AutoComplete filters the value based on the value field alone. Please find the KB link to know more about this.
If you want to filter the data based on the CustomerID, then can change in the Filtering event with help of Filter method as mentioned in the below code example. Also, please share the use case for mapping different field for AutoComplete component that will help us to check and proceed further at our end.
@page "/"@inject IJSRuntime JSRuntime;@using ClientHost.Data@using Syncfusion.Blazor@using Syncfusion.Blazor.DropDowns@using Syncfusion.Blazor.Data<SfAutoComplete @ref="AutoObj" TValue="int" TItem="Orders" Placeholder="Select a Employee" AllowFiltering="true" @bind-Value="@AutoVal"><SfDataManager Url="api/Default" Adaptor="Adaptors.WebApiAdaptor" CrossDomain="true"></SfDataManager><AutoCompleteFieldSettings Value="OrderID" Text="CustomerID" /><AutoCompleteEvents TValue="int" TItem="Orders" Filtering="onFiltering"></AutoCompleteEvents></SfAutoComplete>@code{SfAutoComplete<int, Orders> AutoObj;public Query Query = new Query();public int AutoVal { get; set; } = 2;public void onFiltering(FilteringEventArgs args){args.PreventDefaultAction = true;Query = new Query().Where(new WhereFilter(){Field = "CustomerID",value = args.Text,Operator = "startswith",IgnoreCase = true}).Take(10);this.AutoObj.Filter(null, Query);}}
Regards,Berly B.C