clear search results when clicked on a button from another widget

590
3
04-04-2018 11:15 AM
esriuser2
New Contributor II

I have a default search widget.

When I click on a button in another widget , i want to clear the results from the search widget. Below is how I tried but not clearing the text from the search widget. Can I call the method(_onClearSearch) of the search widget from the other widget? Any ideas?

let _searchWidget = this.widgetMan.getWidgetsByName('Search');
on.emit(query(".searchClear"), 'click', _searchWidget[0]._onClearSearch);

Thanks for your help!

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

The code should look like this:

let _searchWidget = this.widgetMan.getWidgetsByName('Search');
on.emit(query(".searchClear"), 'click', lang.hitch(this, function(){
  _searchWidget[0]._onClearSearch();
}));‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
esriuser2
New Contributor II

Thank you Robert!

I tried as you mentioned , but still not firing the _onClearSearch method.Anything else I am missing?

let _searchWidget = this.widgetMan.getWidgetsByName('Search');
on.emit(query(".searchClear"), 'click', lang.hitch(this, function(){
  _searchWidget[0]._onClearSearch;
}));
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

I edited my code post (above) to actually invoke the method. Try that.

0 Kudos