unable to clear search result from the parent component
abearat opened this issue · 1 comments
abearat commented
Hi All,
i have parent component that is using 2 of the custom c-lookup. i have a cancel button on the ui. when the user click on the button i need to clear all the selection. i tried below lines but did not work. Do you know any other way to do that.
var lookups = this.template.querySelectorAll('c-lookup');
if(lookups && lookups.length > 0){
for (let i = 0; i < lookups.length; i++) {
lookups[i].handleClearSelection();
}
}
abearat commented
figured it out create below method in the child comp
@api handleClearSelectionFromParent() {
this._curSelection = [];
this._hasFocus = false;
// Process selection update
this.processSelectionUpdate(true);
}
then use below lines to call method
var lookups = this.template.querySelectorAll('c-lookup');
if(lookups && lookups.length > 0){
for (let i = 0; i < lookups.length; i++) {
lookups[i].handleClearSelectionFromParent();
}
}