Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143496 | Mar 22,2019 04:41 PM UTC | Apr 17,2020 01:08 PM UTC | Angular - EJ 2 | 13 |
![]() |
Tags: DropDownList |
// assign the dataSource here
this.dropdownObj.dataBind(); // where this.dropdownObj refers to control's instance |
<ejs-dropdownlist #employees id='employees' [dataSource]='data' [fields]='fields' [popupHeight]='height'
[placeholder]='watermark'>
<ng-template #itemTemplate let-data>
<div>
<div class="ename"> {{data.FirstName}} </div>
<div class="job"> {{data.Designation}} </div>
</div>
</ng-template>
<ng-template #valueTemplate let-data>
<div>
<div class="name"> {{data.FirstName}} </div>
</div>
</ng-template>
</ejs-dropdownlist>
|
ngAfterViewInit(){
var proxy = this.dropdownlist;
document.getElementById('btn').addEventListener('click', function () {
const Http = new XMLHttpRequest();
const url = 'https://ej2services.syncfusion.com/production/web-services/api/Employees';
Http.open("Get", url);
//Http.setRequestHeader('Content-Type', 'application/json');
Http.send();
Http.onreadystatechange = function (args) {
if (Http.readyState == 4 && Http.status == 200) {
var data = JSON.parse(Http.response);
proxy.dataSource = null;
proxy.dataSource = data;
proxy.dataBind();
}
}
});
} |
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.
This page will automatically be redirected to the sign-in page in 10 seconds.