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

set combobox value & display

Hi,

I use the statement to assign the input value 

 var item = JSON.parse(data);
     for (var i in item) {
         $('#' + i).val(item[i]);
        $('input[name="' + i + '"]').val(item[i]);
     }

But Combobox just display value , It shuld display text message
I could display combobox text message






3 Replies

PO Prince Oliver Syncfusion Team November 12, 2018 06:54 AM UTC

Hi Jeff, 

Thank you for contacting Syncfusion support. 

Based on the shared code, we could see that you have directly bound the value to the control’s input element. To set the value and display the text in the control, make sure that you have bound both the value and text fields and then you need to use the control’s value property. So, we suggest you to set the value for ComboBox using value property. Kindly refer to the following code snippet. 
  
document.getElementById("btn1").addEventListener("click", function () { 
    var item = [{ Id: "game3" }]; 
    var instance = document.getElementById("country").ej2_instances[0]; //Accessing Control’s instance 
    for (var i in item) { 
        instance.value = item[i].Id; //setting using value property 
    } 
}); 

We have attached a sample for your reference, please find the sample at the following location: https://stackblitz.com/edit/ccfc55   

Kindly refer to the following API documentation for Value and Text property 

If the issue persists , Kindly provide additional information on the issue with sufficient code to replicate the issue in our end. It will help us provide solution at the earliest. 

Regards, 
Prince 



JE jeff November 12, 2018 07:49 AM UTC

Hi, 

Could U give me the Javascript EJ1 sample


PO Prince Oliver Syncfusion Team November 12, 2018 08:55 AM UTC

Hi Jeff, 

Thank you for your update. 

Please find the JavaScript example for the EJ1 ComboBox control in the following link: https://jsplayground.syncfusion.com/34hmm2ge 

Regards, 
Prince 


Loader.
Live Chat Icon For mobile
Up arrow icon