How to pass resulting featureSet to Screening Widget with feature action?

862
8
Jump to solution
10-20-2017 09:28 AM
JamalWest2
Occasional Contributor

Currently I have the select widget set  up to open smart editor with a feature action. I created another action to open the screening widget, but can't get the feature/attributes of the selected feature passed to the screening widget automatically. Currently once the screening widget opens I have to select the feature again. How do I populate the screening widget with the selected features automatically within the feature action? I'm very new to WAB.

Here is the code for my feature action- 

   

define([
  'dojo/_base/declare',
  'dojo/_base/lang',
  '../BaseFeatureAction',
  'jimu/utils',
  'jimu/PanelManager',
  'jimu/WidgetManager',
  'dojo/Deferred',
  'dijit/registry'
], function(declare, lang, BaseFeatureAction, utils, PanelManager, WidgetManager, Deferred, registry){
  var clazz = declare(BaseFeatureAction, {
    name: 'PrintTicket',
    iconClass: 'icon-edit',

    isFeatureSupported: function(featureSet){
          
      return featureSet.features.length > 0;
  
    },

    onExecute: function(featureSet){
          WidgetManager.getInstance().triggerWidgetOpen('widgets_Screening_Widget_41')

           .then(function(myWidget) {

                var ticket = featureSet.features[0].attributes;
                console.log(ticket);

                var fName = [];
                fName[0] = featureSet.spatialReference.wkid; 
                fName[1] = featureSet.displayFieldName;
                fName[2] = featureSet.geometryType;
                console.log('log: step 0 '+fName[1] +'  ' + fName[2]);
                
           });
          this.map._extentUtil({ numLevels: 10});
          utils.featureAction.zoomTo(this.map, featureSet.features);
          
    },
          
  });
  return clazz;
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

   

   The console will log all fields and my geometry etc. I'm not sure how to pass feature to Screening widget though.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Jamal,

   The _initToCreateAOIBuffer is expecting an array of graphics and you are trying to use a single graphic.

See my correction on line 11:

onExecute: function(featureSet){
var def = new Deferred();
WidgetManager.getInstance().triggerWidgetOpen('widgets_Screening_Widget_41')
   .then(function(myWidget) {
      console.log("Widget ID is " + myWidget.id);
      var featuresJ = featureSet.features[0];
      var selectionLayerResponse = featuresJ
      console.log("SelectionLayer="+selectionLayerResponse);
      var ticket = featureSet.features[0].attributes;
      console.log(ticket);
      myWidget._initToCreateAOIBuffer(featureSet.features);
      //myWidget._getProcessedPrintData();
      //myWidget._getPrintTemplate();
      var fName = [];
      var widget;
      fName[0] = featureSet.spatialReference.wkid; 
      fName[1] = featureSet.displayFieldName;
      fName[2] = featureSet.geometryType;
      console.log('log: step 0 '+fName[1] +' ' + fName[2]);
 
});

View solution in original post

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Jamal,

  So you are saying line 27 in your code returns null or undefined?

0 Kudos
JamalWest2
Occasional Contributor

Robert,

The Console log returns all of the feature attributes correctly, neither null or undefined. Here is my updated onExecute code.

Robert,

No line 27 returns all of the feature attributes.  I can get everything to return, here is my updated execute code. The issue seems to be that this tool (Screening Widget) doesn't select a feature on the map. It adds a graphic to the map, which it then uses to search the Area of Interest from that graphic and returns all eligible features within that area. Therefore I can't necessarily pass it a feature for it to process. At least that is what my understanding of it has become. I essentially want to be able to select a feature and print that features attributes(with or without map doesn't matter at this point). Is there another way to do this?

      

onExecute: function(featureSet){
var def = new Deferred();
WidgetManager.getInstance().triggerWidgetOpen('widgets_Screening_Widget_41')

   .then(function(myWidget) {
      console.log("Widget ID is " + myWidget.id);
      var featuresJ = featureSet.features[0];
      var selectionLayerResponse = featuresJ
      console.log("SelectionLayer="+selectionLayerResponse);
      var ticket = featureSet.features[0].attributes;
      console.log(ticket);
      myWidget._initToCreateAOIBuffer(selectionLayerResponse);

      //myWidget._getProcessedPrintData();
      //myWidget._getPrintTemplate();
      var fName = [];
      var widget;
      fName[0] = featureSet.spatialReference.wkid; 
      fName[1] = featureSet.displayFieldName;
      fName[2] = featureSet.geometryType;
      console.log('log: step 0 '+fName[1] +' ' + fName[2]);

});

The 3 functions above are from Widget.js of the screening widget. When I call them they are running, but not really taking in my feature as input. There are alot more functions, so I've been going through trying to figure out the order they initialize and run.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Jamal,

   The _initToCreateAOIBuffer is expecting an array of graphics and you are trying to use a single graphic.

See my correction on line 11:

onExecute: function(featureSet){
var def = new Deferred();
WidgetManager.getInstance().triggerWidgetOpen('widgets_Screening_Widget_41')
   .then(function(myWidget) {
      console.log("Widget ID is " + myWidget.id);
      var featuresJ = featureSet.features[0];
      var selectionLayerResponse = featuresJ
      console.log("SelectionLayer="+selectionLayerResponse);
      var ticket = featureSet.features[0].attributes;
      console.log(ticket);
      myWidget._initToCreateAOIBuffer(featureSet.features);
      //myWidget._getProcessedPrintData();
      //myWidget._getPrintTemplate();
      var fName = [];
      var widget;
      fName[0] = featureSet.spatialReference.wkid; 
      fName[1] = featureSet.displayFieldName;
      fName[2] = featureSet.geometryType;
      console.log('log: step 0 '+fName[1] +' ' + fName[2]);
 
});
0 Kudos
JamalWest2
Occasional Contributor

Robert,

Thanks, that did it!! Now I should be able to call the _reportClick function(Not exact function name) to advance through the tool correct? Meaning return the tool as if the report button has been clicked after loading the features.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Jamal,

  Sorry I don't use the Screening Widget so I am not real familiar with it.

0 Kudos
JamalWest2
Occasional Contributor

Ok , thanks for your help though.

0 Kudos
DrewMerrill1
New Contributor III

Hey Jamal,

Have you tried customizing the report output within the screening widget?  I would like to add some additional summary data but am not sure how. Any help would be much appreciated.  Thanks!

0 Kudos
JamalWest2
Occasional Contributor

I ended up not using the screening widget. We made a custom report. I would use that instead if I were you.

0 Kudos