How to get the value of the selected item of Combo box

Hi,
I need to get the selected item's value rather than text in the combo box. But it always return the text. Please help me to solve this matter.

View

@{
    Html.EJ()
       .ComboBox("LocList")
       .AllowFiltering(true)
       .ComboBoxFields(h => h.Text("Text").Value("Value"))
       .Query("new ej.Query().select(['Text','Value']).take(50)")
       .ClientSideEvents(h => h.Filtering("filtering").Change("change"))
    
       .Datasource((IEnumerable<Object>)ViewBag.Locations)
       .Placeholder("Select a Location")
       .Render();
}

    <script type="text/javascript">
          

            function change(args) {
           
                if ($('#LocList').val() != null) {
                    $.ajax({
                        url: '@ViewBag.RootFolder' + '/TransactionDateSetup/TransactionDateSetup',
                        type: "POST",
                        data: { Loc_Key: $('#LocList').val() },
                        success: function (result) {

                            var obj2 = $("#FlatGrid").ejGrid("instance")
                            obj2.dataSource(result);

                            //var obj3 = $("#Grid").ejGrid("instance")
                            //obj3.dataSource(result);

                        },
                        error: function () {
                        }
                    });
                }
            }

       </script>



2 Replies

KA kalum May 13, 2018 02:17 PM UTC

Hi,
Can anyone help me on above matter please.
Thank you
Kalum


IB Ilakkiya Baskar Syncfusion Team May 14, 2018 09:05 AM UTC

Hi Kalum, 

Thank you for contacting Syncfusion Support. We suggest you to use the argument of the event to get the text/value in the ComboBox component. Please check the below code,  
@Html.EJS().ComboBox("games").Placeholder("Select a game").PopupHeight( 
                   "230px").DataSource((IEnumerable<object>)ViewBag.localdata).Fields(new ComboBoxFieldSettings { Text = "Game", Value = "Id" }).Render() 
<script> 
function onChange(args){ 
       console.log(args.itemData.Id) //get the value based on the field mapping 
       console.log(args.itemData.Game) //get the text based on the field mapping 
    } 
    </script> 

Let us know if there is any concern, we will be happy to assist you. 

Regards, 
Ilakkiya B 


Loader.
Up arrow icon