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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Get Id of Selected Object

Thread ID:





148964 Nov 9,2019 01:36 PM UTC Nov 11,2019 09:55 AM UTC Blazor 1
Tags: ComboBox
Michael Gerling
Asked On November 9, 2019 01:36 PM UTC

I'm trying to use Combobox to select an item.

Here's my code:

 <EjsComboBox    TValue="SFObject" @ref="Combo" Placeholder="Auswählen" OnChange="LookUp"  @bind-Value="@SelectedSFItem" DataSource="@SFList"  IgnoreAccent=true  FilterType="Syncfusion.EJ2.Blazor.DropDowns.FilterType.Contains">
        <ComboBoxFieldSettings    Value="Name"> </ComboBoxFieldSettings>

SFList ist a List<SFObject> and SFObject Contains several properties. I want to Display the Name property in the Combobox, but I Need my Id Property to consume the selection.

How can I achieve this. It seems there is no DisplayMember/ ValueMember and i can't find the SelectedItem anywhere in my @ref=Combo Object.

The SelectedSFItem also stays empty...

Any suggestions?

Thanks Michael

Narayanasamy Panneer Selvam [Syncfusion]
Replied On November 11, 2019 09:55 AM UTC

Hi Michael,

Greetings from Syncfusion support.

We have validated your requirement. Yes, you can get the selected object’s ID through ItemData by using OnValueSelect event argument. Here you can get ID field by deserializing the ItemsData. Please refer the below code example,
Code example:  
@using Syncfusion.EJ2.Blazor.DropDowns; 
@using Newtonsoft.Json;   
        <EjsComboBox TValue="string" @ref="comboObj" PopupHeight="230px" Index=2 Placeholder="Select a game" DataSource="@Games"> 
            <ComboBoxEvents TValue="string" OnValueSelect="@OnValSelect"> </ComboBoxEvents> 
            <ComboBoxFieldSettings Value="Text"></ComboBoxFieldSettings> 
  public void OnValSelect(Syncfusion.EJ2.Blazor.DropDowns.SelectEventArgs args) 
        string output = JsonConvert.SerializeObject(args.ItemData); 
       var SelectedID = JsonConvert.DeserializeObject<GameFields>(output).ID; 

Let us know if you need further assistance on this.

Narayanasamy P.


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