WAB print widget

2243
5
Jump to solution
02-20-2017 11:45 PM
AveKargaja
Occasional Contributor

Hey

I have got a question about WAB dev edition print widget configuration. 

Is it possible to configure the print widget to show in the widget drop-down selection menu only some of the print service layouts? So that when my print service has for example layout templates "template1", "template2" and "template3", then I can show templates "template1" and "template2" in one app and templates "template1" and "template3" in another app.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Ramon,

   In the Print.js file I modify the _handlePrintInfo function to remove a layout and remove some formats too (see my comments in the function):

    _handlePrintInfo: function(rData) {
      if (!rData.isGPPrint) {
        domStyle.set(this.layoutDijit.domNode.parentNode.parentNode, 'display', 'none');
        domStyle.set(this.formatDijit.domNode.parentNode.parentNode, 'display', 'none');
        domStyle.set(this.advancedButtonDijit.domNode, 'display', 'none');
      } else {
        var data = rData.data;
        domStyle.set(this.layoutDijit.domNode.parentNode.parentNode, 'display', '');
        domStyle.set(this.formatDijit.domNode.parentNode.parentNode, 'display', '');
        domStyle.set(this.advancedButtonDijit.domNode, 'display', '');
        var Layout_Template = array.filter(data.parameters, function(param) {
          return param.name === "Layout_Template";
        });
        if (Layout_Template.length === 0) {
          console.log("print service parameters name for templates must be \"Layout_Template\"");
          return;
        }
        var layoutItems = array.map(Layout_Template[0].choiceList, function(item) {
//Remove the MAP_ONLY layout
        if(item !== "MAP_ONLY"){
          return {
            label: item,
            value: item
          };
        }
//end my change
          // return {
          //   label: item,
          //   value: item
          // };
        });
        layoutItems.sort(function(a, b) {
          return (a.label > b.label) ? 1 : ((b.label > a.label) ? -1 : 0);
        });
        this.layoutDijit.addOption(layoutItems);
        if (this.defaultLayout) {
          this.layoutDijit.set('value', this.defaultLayout);
        } else {
          this.layoutDijit.set('value', Layout_Template[0].defaultValue);
        }

        var Format = array.filter(data.parameters, function(param) {
          return param.name === "Format";
        });
        if (Format.length === 0) {
          console.log("print service parameters name for format must be \"Format\"");
          return;
        }
        var formatItems = array.map(Format[0].choiceList, function(item) {
//Remove the EPS, SVG, and SVGZ formats
        if(item !== "EPS" && item !== "SVG" && item !== "SVGZ"){
          return {
            label: item,
            value: item
          };
        }
//end my change
          // return {
          //   label: item,
          //   value: item
          // };
        });
        formatItems.sort(function(a, b) {
          return (a.label > b.label) ? 1 : ((b.label > a.label) ? -1 : 0);
        });
        this.formatDijit.addOption(formatItems);
        if (this.defaultFormat) {
          this.formatDijit.set('value', this.defaultFormat);
        } else {
          this.formatDijit.set('value', Format[0].defaultValue);
        }
      }
    },

View solution in original post

5 Replies
PanagiotisPapadopoulos
Esri Regular Contributor

You can minimize from ArcGIS Server print service which Layout templates will be available.

So you can create different print services with different Layout options

Tutorial: Publishing additional services for printing—Documentation (10.5) | ArcGIS Enterprise 

this option will allow manage layout options from the print services with out any widget configuration.

0 Kudos
PanagiotisPapadopoulos
Esri Regular Contributor

In order to change, remove or add Layout Templates for the default print service stop print service and edit the Layouts on the following path

C:\Program Files\ArcGIS\Server\Templates\ExportWebMapTemplates

for a second print service create a new folder with layouts on the same path

C:\Program Files\ArcGIS\Server\Templates\

0 Kudos
AveKargaja
Occasional Contributor

Yeah, I'm aware of the option of generating different print services with different layout template folders to my server drive, but this is not the solution I'm looking for because this kind of approach will drain the server memory capabilities as every standalone service will uphold a certain number of instances

And for this excact reason I'm looking for the possibility of WAB widget configuration.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Ramon,

   In the Print.js file I modify the _handlePrintInfo function to remove a layout and remove some formats too (see my comments in the function):

    _handlePrintInfo: function(rData) {
      if (!rData.isGPPrint) {
        domStyle.set(this.layoutDijit.domNode.parentNode.parentNode, 'display', 'none');
        domStyle.set(this.formatDijit.domNode.parentNode.parentNode, 'display', 'none');
        domStyle.set(this.advancedButtonDijit.domNode, 'display', 'none');
      } else {
        var data = rData.data;
        domStyle.set(this.layoutDijit.domNode.parentNode.parentNode, 'display', '');
        domStyle.set(this.formatDijit.domNode.parentNode.parentNode, 'display', '');
        domStyle.set(this.advancedButtonDijit.domNode, 'display', '');
        var Layout_Template = array.filter(data.parameters, function(param) {
          return param.name === "Layout_Template";
        });
        if (Layout_Template.length === 0) {
          console.log("print service parameters name for templates must be \"Layout_Template\"");
          return;
        }
        var layoutItems = array.map(Layout_Template[0].choiceList, function(item) {
//Remove the MAP_ONLY layout
        if(item !== "MAP_ONLY"){
          return {
            label: item,
            value: item
          };
        }
//end my change
          // return {
          //   label: item,
          //   value: item
          // };
        });
        layoutItems.sort(function(a, b) {
          return (a.label > b.label) ? 1 : ((b.label > a.label) ? -1 : 0);
        });
        this.layoutDijit.addOption(layoutItems);
        if (this.defaultLayout) {
          this.layoutDijit.set('value', this.defaultLayout);
        } else {
          this.layoutDijit.set('value', Layout_Template[0].defaultValue);
        }

        var Format = array.filter(data.parameters, function(param) {
          return param.name === "Format";
        });
        if (Format.length === 0) {
          console.log("print service parameters name for format must be \"Format\"");
          return;
        }
        var formatItems = array.map(Format[0].choiceList, function(item) {
//Remove the EPS, SVG, and SVGZ formats
        if(item !== "EPS" && item !== "SVG" && item !== "SVGZ"){
          return {
            label: item,
            value: item
          };
        }
//end my change
          // return {
          //   label: item,
          //   value: item
          // };
        });
        formatItems.sort(function(a, b) {
          return (a.label > b.label) ? 1 : ((b.label > a.label) ? -1 : 0);
        });
        this.formatDijit.addOption(formatItems);
        if (this.defaultFormat) {
          this.formatDijit.set('value', this.defaultFormat);
        } else {
          this.formatDijit.set('value', Format[0].defaultValue);
        }
      }
    },
AveKargaja
Occasional Contributor

Thank You rscheitlin

This is what I looking for, works just the way I need 

0 Kudos