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

Dropdownlist with true or false as values in dataSource

I have a dropdownlist and data value is true or false. This is the data:

public estados: any[] = [ { value: false, text: 'Sin realizar' },{ value: true, text: 'Realizado' }];

And this is the HTML

<ejs-dropdownlist name="estado" [(ngModel)]="model.realizado" [dataSource]='estados' [placeholder]='"Selecciona"' [allowFiltering]='false'></ejs-dropdownlist>

The problem is dropdownlist does not select the ngModel value, always shows placeholder.

Thank you very much.

1 Reply

PO Prince Oliver Syncfusion Team February 18, 2019 10:58 AM UTC

Hi Luis,  

Thank you for contacting Syncfusion support. 

We have checked your code snippet, you have missed to update the ngModel value from component. We have prepared sample based shared code. Please refer the below code snippet. 

[html] 
<ejs-dropdownlist name="estado" [(ngModel)]="realizado" [dataSource]='estados' ></ejs-dropdownlist> 

[component.ts] 
export class DataBindingDropDownListComponent { 
    // define the JSON of data 
    public estados: any[] = [ { value: false, text: 'Sin realizar' },{ value: true, text: 'Realizado' }];   
    public realizado = "Realizado"     
} 

We have attached the sample for your reference, please find the sample at the following location 

Please let us know if you need any further assistance on this. 

Regards, 
Prince 


Loader.
Live Chat Icon For mobile
Up arrow icon