Configure Popup for Search Results

9855
16
01-14-2016 04:31 PM
HamishKingsbury1
Occasional Contributor

Hi All

Using WAB and the default search tool I'm wanting to search some feature layers. I've successfully added the feature layers (three of them) and can search and find specific features. However, what I want to do is configure a custom popup for the returned results (a different template for each of the three). How do I go about doing this? I've searched here and google but haven't come up with anything substantial.

For example, in the below image, I have searched for the area with 'OBJECTID = 1'. The popup that appears shows all the attributes, but I only want the popup to contain (for example) 'TYPE', 'AREA' and 'LENGTH'.

ss+(2016-01-15+at+01.26.36).png

Can anyone help me out? I feel like it may be something fairly simple with the config....

Cheers

Hamish

16 Replies
MattiasEkström
Occasional Contributor III

If you add the feature layers to your web map and configure their Popups, and then use those layer in the search configuration the popup should display as configured.
However to me this seems a bit buggy, sometimes this works and some times it doesn't. It seems like any changes to the map/feature service will require a total reconfiguration of the search widget, and sometime even that doesn't work.

If you configure the search to search a feturelayer that are not included in your webmap you can not configure it's PopUp at all (which annoys me).

If it's your own feature layer and you don't need the other fields in other cases you could hide the fields you don't want to show in ArcMap and republish your service.

0 Kudos
HamishKingsbury1
Occasional Contributor

Cheers for that. I've ended up using Roberts Enhanced Search Widget. I've had to omit the popups, but the widget will show the values for the necessary fields. I hope that the ability to configure popups does get added....

Hamish

0 Kudos
AnninaHirschi_Wyss1
Occasional Contributor III

I encounter the same issue. The Pop Ups are configured in the Web Map (hiding some attributes etc.). In my Web App built with default AGOL Web AppBuilder (not developer), the popups are fine when you click directly on a feature. But, if you perform a search (with the search widget, configured to search in the feature layers of the web map), then the popup shows all the existing attributes, even the hidden ones.

Mattias Ekström wrote:
However to me this seems a bit buggy, sometimes this works and some times it doesn't.

>> For me it NEVER works...

Here is my App: ArcGIS Web Application

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

What is happen is you all as misinterpreting the "Show pop-up for the found feature or location" check box on the Search widgets configuration GUI to mean the web maps configured popup and what the code is doing is just shoeing a popup will all the features fields. You all need to call esri tech support and log an enhancement request for the search widget to use the web maps configured popups instead of this current workflow.

MattiasEkström
Occasional Contributor III

The search result pop up does honor the configured popup for a layer in the web map sometimes.
This is an example from one of my applications, the find parameter does a search and the result popup is my own configuration
http://oskarshamn.maps.arcgis.com/apps/webappviewer/index.html?id=614f8cc6eecb4f7d9d0847740054f7b5&f... 

But when it comes to search sources that are not included in the map, it has to be configured in the search widget configuration which is not possible. I've tried logging enhancement requests but ESRI Sweden only refer to ArcGIS Ideas for that.

0 Kudos
WilliamMiller4
Occasional Contributor II

Hi Robert,

Would it be possible to code which fields are displayed in the pop-up by creating a separate array from the aliasAttrs array that contains the aliasAttrs indexes of the fields you want to include? (widgets/Search/Widget.js, _formatContent, line 378)

Thanks for any help you can provide.

William

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

William,

  I would say yes as long as the field is already in the being returned in that list and you are just wanting to control if it is displayed or not.

0 Kudos
WilliamMiller4
Occasional Contributor II

I tried using the following code to create an array with only specific fields.

var selectedAttrs = {};
selectedAttrs.push(selectedAttrs[2]);
selectedAttrs.push(selectedAttrs[10]);
selectedAttrs.push(selectedAttrs[13]);

...

I also replaced this (lines 396-403):

for (var p in aliasAttrs) {
if (aliasAttrs.hasOwnProperty(p)) {
  content += '<tr valign="top">' +
'<td class="attrName">' + p + '</td>' +
'<td class="attrValue">' + aliasAttrs

+ '</td>' +
'</tr>';
  }
}

with this:

for (var p in selectedAttrs) {
  if (selectedAttrs.hasOwnProperty(p)) {
   content += '<tr valign="top">' +
'<td class="attrName">' + p + '</td>' +
'<td class="attrValue">' + selectedAttrs

+ '</td>' +
'</tr>';
  }
}

It did not work. Any thoughts?

Also, how do you format code to look like code?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

William,

I am a little confused as to what you are adding the selectedAttrs object by using this code?

var selectedAttrs = {};

selectedAttrs.push(selectedAttrs[2]);

selectedAttrs.push(selectedAttrs[10]);

selectedAttrs.push(selectedAttrs[13]);

selectedAttrs is an object, yet you are trying to treat it like and Array that has a push function.

You are also trying to push selectedAttrs[2] when selectedAttrs is just and empty object.

Also, how do you format code to look like code?

Use the "Use advanced editor"  link in the upper right hand corner of a reply (this can not be done from inside the inbox, you have to actually open the thread) and then click the >> button and choose javascript.

0 Kudos