below code is not working, suggest me if i missed something.
<select id="ownerId"
@onchange="ValueChanged"
aria-label="Select a Head/Owner"
data-control="select2"
data-placeholder="Select a country..."
class="form-select form-select-solid form-select-lg fw-semibold">
@foreach (var user in Users)
{
<option value="@user.UserId">@user.Username</option>
}
</select>
private void ValueChanged(ChangeEventArgs e)
{
BiaVM.ProcessOwner = (int)e.Value;
}
Hi,
We check your demo and it seems to be working fine.
Can you try the example below?
<select @onchange="onChange" class="form-select" data-control="select2" data-placeholder="Select an option">
<option></option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
@code {
private string value { get; set; }
private void onChange(ChangeEventArgs e){
value = e.Value.ToString();
}
}
<select @bind="@value" class="form-select" data-control="select2" data-placeholder="Select an option">
<option></option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
I did exactly same thing as u suggested. and also i added below snippet code but i didnt get result
is there anything i should add more or doing wrong. please suggest me.
If i am using wrong version please suggest me in which version it is working
protected override void OnAfterRender(bool firstRender)
{
JS.InvokeVoidAsync("KTApp.init");
}
Hi,
This should work out of the box without any additional initialization.
Do you have this issue only with select2 inputs?
Can you try html plain select for test?
Regards,
Lauris Stepanovs,
Keenthemes Support Team
I'm having the same problem. The example is as follows.
<select class="form-select form-select-solid" data-control="select2" data-placeholder="Seçim yapınız..." data-allow-clear="true"
@onchange="@((ChangeEventArgs __e) => SelectedValue = __e?.Value.ToString())">
<option></option>
@foreach (var item in Select2Data)
{
<option value="@item.Id">@item.Name</option>
}
</select>
<span>Seçim value: @(SelectedValue)</span>
@code{
private string SelectedValue { get; set; } = "2";
protected override async void OnInitialized()
{
Select2Data = new List<Data>();
Select2Data.Add(new Data() { Id = "1", Name = "Liste 1" });
Select2Data.Add(new Data() { Id = "2", Name = "Liste 2" });
Select2Data.Add(new Data() { Id = "3", Name = "Liste 3" });
Select2Data.Add(new Data() { Id = "4", Name = "Liste 4" });
Select2Data.Add(new Data() { Id = "5", Name = "Liste 5" });
Select2Data.Add(new Data() { Id = "6", Name = "Liste 6" });
}
}