SfDropDownList ValueTemplate - Displays the previous selected value

Hi,
If I define a ValueTemplate for SfDropDownList, then the control shows the previously selected value, not the current.

Example, steps to reproduce:

1. You have a dropdown with items A,B and C, and a simple ValueTemplate is defined. Initially A is selected.
2. If change to B, then the control shows A. (A was the previous value)  (Expected: B)
3. If you select C, the control shows B, because it was the previous selected value.  (Expected: C)
4. If you select A, the control shows C, because it was the previous selected value.  (Expected: A)

If I don't specify ValueTemplate, then the control works fine.

You can reproduce with the example from your documentation:

Regards,
 Peter

7 Replies

SP Sureshkumar P Syncfusion Team May 29, 2020 08:57 AM UTC

Hi Németh, 
 
Greetings from Syncfusion support. 
 
Based on your shared information with documentation link. We suspect that you have facing the reported issue when click the “Team lead” again and again. The reason behind the issue is we have mapped the value field as Designation. That field leads to the duplicate value as present twice in the list. So, when select the second team lead designation that showcased first team lead name. we suggest you change the value field mapped variable as FirstName as linke below code example to resolve the issue.  
 
Kindly check the code example. 
 
 
@using Syncfusion.Blazor.Data 
@using Syncfusion.Blazor.DropDowns 
 
<SfDropDownList TValue="string" TItem="EmployeeData" Placeholder="Select a customer" Query="@Query"> 
    <DropDownListTemplates TItem="EmployeeData"> 
        <ItemTemplate> 
            <span><span class='name'>@((context as EmployeeData).FirstName)</span><span class='destination'>@((context as EmployeeData).Designation)</span></span> 
        </ItemTemplate> 
        <ValueTemplate> 
            <span>@((context as EmployeeData).FirstName) - @((context as EmployeeData).Designation)</span> 
        </ValueTemplate> 
    </DropDownListTemplates> 
    <SfDataManager Url="https://ej2services.syncfusion.com/production/web-services/api/Employees" Adaptor="Syncfusion.Blazor.Adaptors.WebApiAdaptor" CrossDomain="true"></SfDataManager> 
    <DropDownListFieldSettings Text="FirstName" Value="FirstName"></DropDownListFieldSettings> 
</SfDropDownList> 
 
@code { 
    public class EmployeeData 
    { 
        public string FirstName { get; set; } 
        public string Designation { get; set; } 
    } 
    public Query Query = new Query(); 
} 
 
<style> 
    .destination { 
        right: 15px; 
        position: absolute; 
    } 
</style> 
 
 
We have prepared the sample based on your requirement. please find the sample here: https://www.syncfusion.com/downloads/support/directtrac/general/ze/DDL-2062308899  
 
Also, we will change our documentation and will intimate you once the documentation has been published.  
 
Regards, 
Sureshkumar P 



PN Péter N May 29, 2020 09:59 AM UTC

Hi,

Thank you!

I am sorry, but I forgot to write, that I use it in WebAssembly app. It works fine on server side, but not on client side.

I attached the webassembly version of the sample app.

Regards, 
 Peter





Attachment: SampleApp_1b42684a.zip


SP Sureshkumar P Syncfusion Team June 2, 2020 10:44 AM UTC

Hi Németh,  
 
Thanks for your detailed update with sample. 
 
We have confirmed displays previous value using value template as bug in our end and include the fix in the Volume-2 release, which is scheduled on end of June 2020. We appreciate your patience until then  
 
You can track the status of the bug from the below feedback link.  
 
Regards, 
Sureshkumar P  



PN Péter N June 2, 2020 10:47 AM UTC

Thank you very much!
Regards,
 Peter


SP Sureshkumar P Syncfusion Team June 3, 2020 04:05 AM UTC

Hi Péter, 
 
Thanks for your update. We will get back to you once the fix will be included in our Volume-2 main release. We appreciate your patience. 
 
Regards, 
Sureshkumar P 



PN Péter N June 3, 2020 06:35 AM UTC

Hi Sureshkumar,

I updated to 18.1.0.55 and suddenly it works fine.

Thank you very much!
Regards,
 Peter


SP Sureshkumar P Syncfusion Team June 3, 2020 06:47 AM UTC

Hi Péter, 
 
Thanks for your update.  
 
Regards, 
Sureshkumar P 


Loader.
Up arrow icon