Paging results in Popup class in JS API 3.4

1688
9
05-06-2013 12:56 PM
Jay_Gregory
Occasional Contributor III
I have never understood how to implement a paging infoWindow using the Popup class in any of the infoWindows?  Now that popups are the default infoWindow for v 3.4 of the JS API, I was wondering if someone could post some code on how to ensure that the infoWindow / popup will have paging options when click on a location with multiple markers. 

Thanks!
0 Kudos
9 Replies
MartynSmith
New Contributor
Also wondering same thing here
0 Kudos
ReneRubalcava
Frequent Contributor
I never really thought about it, but the paging is set up by the number of features associated with the popup.
http://developers.arcgis.com/en/javascript/jsapi/popup.html#setFeatures
When setFeatures is used the title area displays the number of features and the index of the currently selected feature and ignores the title defined in the info template. If you want to display title text you will need to specify it as part of the info window content.


Think like on an Identify function; you grab multiple features and set their infoTemplate content and stuff those features into a popup via setFeatures, then use show() to display it somewhere.
0 Kudos
Jay_Gregory
Occasional Contributor III
I was under the impression that all this was handled under the hood, and no real additional coding was necessary.  Otherwise you'd have to set a search radius and loop through all the results to show in the popup right? 
I tried following the demo at http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/widget_popupfl.html and I still don't get paging...but the Popup dijit reference page shows properties "pagingControls" and "pagingInfo" (both default to true), that should elegantly handle the paging, right?

Jay
0 Kudos
MartynSmith
New Contributor
I did find a resolution to my issue.  For me, changing the feature layer selection mode from "MODE_SELECTION" to "MODE_SNAPSHOT" enabled paging in the popup for me
0 Kudos
Jay_Gregory
Occasional Contributor III
Thanks!  That's a good tip - I just tried doing that and it still didn't work for me.  Would you mind posting your code?

Jay
0 Kudos
MartynSmith
New Contributor
Jay-

I'm using a json feature collection to populate a feature layer.  Similar to the example shown here (except this is using an ArcGIS server feature layer): 

http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/fl_popup.html
0 Kudos
Jay_Gregory
Occasional Contributor III
Thanks!  I got it working - I had to add a FeatureLayer twice - one in selection mode with the popup template to handle the query and infoWindow contents, and a second time in ONDEMAND mode to simply show the data when one loads the map.  Seems a bit unnecessary that I have to add the same layer twice to handle this functionality, but if that is the preferred way to do it then so be it!

Thank you so much for your help!

Jay
0 Kudos
MartynSmith
New Contributor
Glad you got it working.  The API documentation for FeatureLayer needs some work to say the least.  I just got there by trial and error my self.  You'l see in the sample they add the layer twice as well.
0 Kudos
KevinMacLeod1
Occasional Contributor III
Glad you got it working.  The API documentation for FeatureLayer needs some work to say the least.  I just got there by trial and error my self.  You'l see in the sample they add the layer twice as well.


Does this affect the AGS JS TOC, and list it twice there? If so and that is indeed how it's designed as of now in the API, that would be important to fix in API 3.5+. Many of us here use AGS JS TOC! :cool:

For my current site I am using Identify from the Sample code which seems to have this built in. But on our other site I added everything as feature layers, in 3.3, and used Query Task with search radius. Added each only once. I was also surprised no paging was there. Wasn't sure why and this was on a research to do list.. Thank you to everyone that posted here! I will also try this workaround eventually for our other site, post whether it works for us!
0 Kudos