|
// initialize ComboBox component
let dropdownOBj: DropDownList = new DropDownList({
// bind the DataManager instance to dataSource property
dataSource: new DataManager({
url: 'https://ej2services.syncfusion.com/production/web-services/api/Employees',
adaptor: new WebApiAdaptor,
crossDomain: true
}),
// bind the Query instance to query property
query: new Query().select(['FirstName', 'EmployeeID']).take(10).requiresCount(),
// map the appropriate columns to fields property
fields: { text: 'FirstName', value: 'EmployeeID' },
// set the placeholder to ComboBox input element
placeholder: 'Select a name',
// set the height of the popup element
popupHeight: '200px',
// sort the resulted items
sortOrder: 'Ascending',
created: function(args){
(dropdownOBj.element as any).value = "Janet Leverling";
},
dataBound: function(args){
dropdownOBj.value = "3";
}
});
dropdownOBj.appendTo('#customers');
|