Select to view content in your preferred language

Search Widget Question

666
4
Jump to solution
02-07-2018 09:53 AM
deleted-user-bWhhezP4R-ec
Deactivated User

Hi,

I am trying to make a Search History widget to archive searches done in the WAB Search widget. I want to make it so that the Search History widget can pass a previous search to the Search widget, and then the Search widget will automatically perform a search on that previously searched term. I am running into a problem passing the data from the History widget to the Search widget. My code in the History widget is:

_testPublish:function(search){
this.publishData({"searchString":search);
},

In the Search widget, I have added the Search History widgets' name to the listenWidgetsIds array, and I modified its onReceiveData method to handle the data from the History widget. 

onReceiveData: function(name, widgetId, data, hisData) {
if (name === 'framework' && widgetId === 'framework' && data && data.searchString) {
this.searchDijit.set('value', data.searchString);
this.searchDijit.search();
}else if(name === 'History' && data && data.searchString){ // Get text from History Widget and perform the search
this.searchDijit.set('value', data.searchString);
this.searchDijit.search();
}

However, this has not been working. The Search Widget is not populating with the search. In fact, I can't get the onReceiveData method in the Search widget to trigger at all. Are there any simple mistakes that I'm making with this? Or is there a better way to populate the Search widget programmatically with a search?

Thanks for your help!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Cameron,

   What value did you add to the Search widgets listenWidgetIds? The Widgets Id is unique and not the same as the widgets name. You can get the widget ID from the app config.json file.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Cameron,

   What value did you add to the Search widgets listenWidgetIds? The Widgets Id is unique and not the same as the widgets name. You can get the widget ID from the app config.json file.

NathanHeickLACSD
Frequent Contributor

Hi Robert,

How do you specify the listenWidgetIds?  When I try to add it to the widget config like the comments in BaseWidget, it doesn't recognize it.  I'm pretty sure it will work if I do it in the JavaScript, but it's better to have it in the config file.

Thanks,
Nathan

0 Kudos
NathanHeickLACSD
Frequent Contributor

The problem was that I was editing the wrong config file.  I was editing the template in the widget folder, not the one in the config folder.

0 Kudos
deleted-user-bWhhezP4R-ec
Deactivated User

Ha! That was it. I put the name in, not the id.

Thanks a lot Robert!

0 Kudos