Thank you Marin. As suggested by you, we have implemented this workaround and working fine.
Also It would be really helpful if this is fixed in subsequent releases.
Here is a reproducible and a workaround (highlighted in green):
<p>repro: select "item 4", click the button. Expected: the text in the DDL changes. Actual: only the text in the dropdown changes</p>
@OriginAgentID
<TelerikButton OnClick="@ChangeItem">Change item 4</TelerikButton>
<TelerikDropDownList Class="dropdown-combo-small " Width="230px" OnChange="OriginAgentChange"
PopupHeight="auto" Data="@OriginAgentList" TextField="CompanyName" ValueField="AgentID"
@bind-Value="@OriginAgentID" DefaultText="Select">
</TelerikDropDownList>
@code {
protected override async Task OnInitializedAsync()
{
OriginAgentList = Enumerable.Range(1, 10).Select(x => new MyDdlModel { CompanyName = "item " + x, AgentID = x }).ToList();
}
async Task ChangeItem()
{
await Task.Delay(500);//simulate database wait
//change data
OriginAgentList[3].CompanyName = "changed at " + DateTime.Now.Millisecond;
//create a new reference so the OnParametersSet of the component fires and it can know there is new data
OriginAgentList = new List<MyDdlModel>(OriginAgentList);
int currSelectedItem = OriginAgentID;
OriginAgentID = 0;
StateHasChanged();
//add this if it does not work
//await Task.Delay(30);//wait a rendering frame
OriginAgentID = currSelectedItem;
//add this if it does not work
//StateHasChanged();
}
void OriginAgentChange(object theUserInput)
{
Console.WriteLine(theUserInput);
string result = string.Format("The user selected: {0}", (int)theUserInput);
}
public class MyDdlModel
{
public int AgentID { get; set; }
public string CompanyName { get; set; }
}
List<MyDdlModel> OriginAgentList { get; set; }
int OriginAgentID { get; set; }
}
Regards,
Marin Bratanov
Progress Telerik