// get the typed characters
var customValue = document.getElementsByClassName("e-input-filter")[0]
.value;
// make new object based on typed characters
var newItem = { Name: customValue, Code: customValue };
// new object added to data source.
ddlObj.dataSource.push(newItem);
// close the popup element.
ddlObj.hidePopup();
// pass new object to addItem method.
ddlObj.addItem(newItem);
// select the newly added item.
ddlObj.value = customValue;
}; |
// initialize DropDownList component
var dropDownListObj = new ej.dropdowns.DropDownList({
// set the employees data to dataSource property
dataSource: window.ddEmployeesList,
// map the appropriate columns to fields property
fields: { text: "Name" },
valueTemplate: '<div class="name"> ${Designation} </div></div>',
// set the placeholder to DropDownList input element
placeholder: "Select an employee",
// set the height of the popup element
popupHeight: "270px"
});
dropDownListObj.appendTo("#employees"); |