Printing Popup Contents

16453
75
Jump to solution
10-26-2016 12:42 AM
ÇankayaBelediyesi
New Contributor III

I have a Web Mapping Application with a standard Print Widget. I would like to include the contents of the popup window in the printout.

Here is an example:

GIS Portal for the City of Abilene, TX

Standard printout:

Standard printout

Popup window:

Popup window

Desired printout:

Desired printout

My research so far:

There is a BLOG POST by esri explaining how to do this. This post shows 2 methods. The first method is not suitable for my purposes cause it requires manual data entries for each printout. The second method seems incomplete, Format & Layout_Template parameters are missing. Print does not work even if I add those parameters manually before publishing the service. If the second method worked properly, I would have modified it to match my needs, unfortunately it doesn't.

http://stackoverflow.com/questions/32363943/arcgis-javascript-web-map-printout-with-popup-shown

dojoOn(map.infoWindow, "selection-change", function(){ //build custom text here }

My knowledge on JavaScript is limited, so I couldn't manage what he explained here. Where am I supposed to add this and what should I include in the function?

http://gis.stackexchange.com/questions/111360/populate-a-layout-text-element-with-the-description-fr...

We have the print button generating an html page that pulls data from the database and formats it in pretty much an exact replica of the .mxd we were using. For the map it uses a function on the rest endpoint to generate an image from the map service.

This seems even more complicated than the others.

Either one the above solutions works for me.

  1. add popup contents at the bottom of the print layout
  2. make use of "selection-change" event
  3. generate a new html page
  4. any other suggestion

TL;DR I want to include popup window or it's contents in the printout.

Thanks in advance.

75 Replies
RichBell
Occasional Contributor

I think I understand the logic but I have no idea where this code is supposed to go?

Have been trying all sorts of things.

Should it reside in the print.js file?

Rich

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rich,

   You are wanting to format the data before it goes to the print so, yes you would do that in the print.js

example:

require(["dojo/date/locale", ...], function(locale, ...){
....
obj = {SALEDATE: "Sales Date: " + locale.format( gra.attributes.SALEDATE, {selector:"date", datePattern:"MMM d, yyyy"} );
0 Kudos
RichBell
Occasional Contributor

Thank You,

I was able to change the format of numeric fields, but I am doing something wrong with the date values.

When I add "locale" to the format string the Print widget bombs out and will not create a print. Something is incorrect in one of the attached images. Any further help would greatly be appreciated?

P1P2

Thank You!

Rich

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rich,

   Did you add the require for locale to the existing requires in the js file?

0 Kudos
RichBell
Occasional Contributor

I believe so? I'm still learning....I added what is in the attached images.

p3

p4

What am I missing?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rich,

   I am not sure why you added those two function commented with BELL ADDITION in your code. There should be no need for those.

0 Kudos
RichBell
Occasional Contributor

Ahh! I deleted the BELL ADDITIONS. That was from my first attempt at this.

I do not know where to add the Require in the file

0 Kudos
RichBell
Occasional Contributor

Ok, I am still at a loss! Tried my best.. What am I doing wrong? The "SALEDATE" date field will not format correctly.

P4 

0 Kudos
RichBell
Occasional Contributor

Robert,

I found the Print Format issue.

This is the correct string to format the dates.

p5

JeffWilcox1
New Contributor III

just a heads up, although this code works well, I discovered that null values will be displayed as "12/31/1969" aka null by the standards of Unix Time Epoch. Here's something that I put together to leave null dates blank:

if (gra.attributes.dateCheck !== null) {
obj = { dateCheck: locale.format(new Date(gra.attributes.dateCheck), {
selector: 'date',
datePattern: "MM'/'dd'/'yyyy"
})};
} else {
obj = { dateCheck: ""}
}
cTextElements.push(obj);

0 Kudos