| let dropDownListObj: DropDownList = new DropDownList({ // bind the DataManager instance to dataSource property dataSource: new DataManager({ url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers', adaptor: new ODataV4Adaptor, crossDomain: true }), // bind the Query instance to query property query: new Query().select(['ContactName', 'CustomerID']).take(25), // map the appropriate columns to fields property fields: { text: 'ContactName', value: 'CustomerID' }, // set the placeholder to DropDownList input element placeholder: 'Select a customer', // sort the resulted items sortOrder: 'Ascending', // set the height of the popup element popupHeight: '200px' }); dropDownListObj.appendTo('#customers'); |
| document.getElementById('first').onclick = () => { let dataSource: any = new DataManager({ url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers', adaptor: new ODataV4Adaptor, crossDomain: true }); let query: query = new Query().select(['ContactName', 'CustomerID']).take(1); dataSource.executeQuery(query).then((e: any) => { dropDownListObject.addItem({ Id: e.result[0].CustomerID, Game: e.result[0].ContactName }, 0); } |