<DropDownListComponent id="customvalue" ref={ComboBox => {this.listObj = ComboBox; }} dataSource={this.searchData} filtering={this.onFiltering.bind(this)} allowFiltering={true} fields={this.fields} noRecordsTemplate={this.template} placeholder="Select a country" popupHeight="270px"/>
this.onFiltering = e => {
let query = new Query();
query = e.text !== "" ? query.where("Name", "startswith", e.text, true) : query;
e.updateData(this.searchData, query);
let proxy = this;
if (document.getElementById("nodata")) {
document.getElementById("btn").onclick = function() {
// get the typed characters
let customValue = document.getElementsByClassName("e-input-filter")[0].value;
// make new object based on typed characters
let newItem = { Name: customValue, Code: customValue };
// new object added to data source.
proxy.listObj.dataSource.push(newItem);
// close the popup element.
proxy.listObj.hidePopup();
// pass new object to addItem method.
proxy.listObj.addItem(newItem);
// select the newly added item.
proxy.listObj.element.value = customValue;
};
}
};
}
|
|
this.onFiltering = e => {
let IsCustom = true;
let query = new Query();
// frame the query based on search string with filter type.
query =
e.text !== "" ? query.where("Name", "startswith", e.text, true) : query;
// pass the filter data source, filter query to updateData method.
e.updateData(this.searchData, query);
let proxy = this;
// document.getElementById("btn").onclick = function() {
this.listObj.filterInput.addEventListener("keydown", function(e) {
if (e.key == "Enter" && IsCustom) {
// get the typed characters
let customValue = document.getElementsByClassName("e-input-filter")[0]
.value;
// make new object based on typed characters
let newItem = { Name: customValue, Code: customValue };
// new object added to data source.
proxy.listObj.dataSource.push(newItem);
// close the popup element.
proxy.listObj.hidePopup();
// pass new object to addItem method.
proxy.listObj.addItem(newItem);
// select the newly added item.
proxy.listObj.element.value = customValue;
IsCustom = false;
}
});
IsCustom = true;
};
}
|