Issue setting values

So I updated to 18.3.xx and it seemed to of break everything with the MultiSelect control. Another issues I have is trying to update the values in code. I need to be able to add values to the List using the Add method (adding using a foreach). For testing if I put the myList.Add("xxx") in the initialize procedure it works, but if a put it in a function and call that function, say by a button click, the value in the control do not update. Interesting if I do amylist = new List(new string[] { "Game5" });in a function,thatwill work. For some reason the .Add outside theOnInitialized()does not update the control Value.
All this worked perfectly in 18.2.59 though.
So I just included a screen shot of the code because trying paste code in here is a extremely painful experience.
You have tried to enter a word or URL that is not allowed on this site. If you believe that this is inaccurate, please contact us at [email protected].


1 Reply 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team October 14, 2020 01:50 PM UTC

Hi Michael, 


Greetings from Syncfusion support. 


We would like to thank you for helping us to understand your requirement much better. We have checked the attached project. On seeing the code snippet, you have used List<string> for value property. We would like to know you that we have already considered this case as improvement in our end. Therefore we suggest you to use type of value as string[] to resolve the issue. Please find the code snippet below.

 
@using System.Collections.ObjectModel 
<div class="control-section"> 
    <div class="control_wrapper"> 
        <div id='content'> 
            <div> 
                <h4> Default Mode</h4> 
                <SfMultiSelect TValue="string[]" @bind-Value="mylist" Mode="@VisualMode.Default" Placeholder="Favorite Sports" DataSource="@Games"> 
                    <MultiSelectFieldSettings Text="Text" Value="ID"></MultiSelectFieldSettings> 
                </SfMultiSelect> 
            </div> 
        </div> 
    </div> 
</div> 
<button type="button" @onclick="setGames">Set Games</button> 
 
@code{ 
 
    public class GameFields 
    { 
        public string ID { get; set; } 
        public string Text { get; set; } 
    } 
private List<GameFields> Games = new List<GameFields>() 
{ 
        new GameFields(){ ID"Game1"Text"American Football" }, 
        new GameFields(){ ID"Game2"Text"Badminton" }, 
        new GameFields(){ ID"Game3"Text"Basketball" }, 
        new GameFields(){ ID"Game4"Text"Cricket" }, 
        new GameFields(){ ID"Game5"Text"Football" }, 
        new GameFields(){ ID"Game6"Text"Golf" }, 
        new GameFields(){ ID"Game7"Text"Hockey" }, 
        new GameFields(){ ID"Game8"Text"Rugby"}, 
        new GameFields(){ ID"Game9"Text"Snooker" }, 
        new GameFields(){ ID"Game10"Text"Tennis"}, 
    }; 
 
    string[] mylist = new string[] { }; 
 
 
   
 
    private void setGames() 
    { 
 
        mylist = new string[] { "Game5""Game6" }; 
 
    } 
 
} 
 



Regards, 
Sevvandhi N 


Marked as answer
Loader.
Up arrow icon