Publish data from search widget to eSearch widget

436
1
11-03-2017 09:23 AM
ZhujingXia
Occasional Contributor II

Hi Robert,

I used your eSearch widget for a while now. I'd like to see how to pass the search result from the search widget to your eSearch widget and do the by spatial to intersected with another feature layer.

I put this code in the Startup:Function

 this.fetchDataByName('Search');

and  this code in the onReceiveData:Funtion()

console.log(data.searchResults)

But it does not work. Could you let me know how to pass the search result to your widget?

Thanks

0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus

Zhujing,

   The eSearch is already setup to listen for all publishData events. So all you have to do is add code to the existing onReceiveData function in the eSearch widget to deal with what ever it is you are trying to get from the search widget.

      onReceiveData: function(name, widgetId, data) {
        if(name === 'Search' && data.searchResults){
          //do something with data.searchResults
          console.info(data.searchResults);
        }
        ...‍‍‍‍‍‍