We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Blazor EjsMultiSelect - how to programatically set the selected items

Thread ID:

Created:

Updated:

Platform:

Replies:

144574 May 10,2019 03:15 PM UTC May 15,2019 11:04 AM UTC ASP.NET MVC - EJ 2 1
loading
Tags: MultiSelectDropdown
Andrew
Asked On May 10, 2019 03:15 PM UTC

I am using the Blazore EjsMultiSelect. I populate the list of values as such:

<EjsMultiSelect ref="dropdown" DataSource="@CloudCredentials" Fields="@SelectCredentialsFieldSettings"></EjsMultiSelect>

        protected override async Task OnAfterRenderAsync()
        {
                CloudCredentials = (await _userService.GetUser()).CloudCredentials.OrderBy(i => i.FriendlyName).ToList();
                dropdown.DataSource = CloudCredentials;
                dropdown.DataBind();
            }
        }

Can you tell me how to programatically select specific items in the dropdown, such that specific chips are shown after OnAfterRenderAsync() completion?

Prince Oliver [Syncfusion]
Replied On May 15, 2019 11:04 AM UTC

Hello Andrew, 

Thank you for contacting us. 

We have checked the reported scenario. To programmatically select specific items in the dropdown and be displayed after rendering the component, we can achieved it by using value property. In MultiSelect component value property is defined as array of strings. Kindly refer to the following code snippet. 

<EjsMultiSelect ref="@MultiSelectObj" ID="local" PlaceHolder="Select countries" DataSource="@localdata" Fields="@MultiSelectFieldSettings"></EjsMultiSelect> 
 
EjsMultiSelect MultiSelectObj; 
 
@functions{ 
    public sting[] multiSelectValue; 
    protected override async Task OnAfterRenderAsync() 
    { 
        localdata = new List<object> 
        { 
            new { Name = "Australia", Code = "AU" }, 
            new { Name = "Bermuda", Code = "BM" }, 
        }; 
        MultiSelectObj.DataSource = localdata; 
        MultiSelectObj.DataBind(); 
        multiSelectValue = new string[] { "BM" }; 
        MultiSelectObj.Value = multiSelectValue; 
    } 
    public object MultiSelectFieldSettings = new { text = "Name", value = "Code" }; 
} 

We have attached a sample for your reference, please find it in the following location:  

Let us know if you need any further assistance on this. 

Regards, 
Prince 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon