How do I connect to another widget from within my custom widget?

3170
12
Jump to solution
05-30-2018 09:53 AM
Labels (1)
RyanBrenner1
Emerging Contributor

I am looking to call the Select Widget within my own custom widget. The idea is to use the select widget to get the selected area, then post that collected information and send it to my custom widget where it will be used to query my file server using ASP where it will then be populated into a dgrid in a panel. I do NOT want to have the Select widget added to my WAB and do not want the user to have access to this first and then have to click on my custom widget. I only want the user to click once, on my custom widget, in order to give the search results in a dgrid table based on their selection.

I have been told there is a way to call another widget, activate it as hidden, use it, and then populate my dgrid with the passed over information. There seems to be no documentation that I can find on how to do this in detail, let along an example of calling another widget to use its functionality. Does anyone have an idea on how to do this without building your own code or modifying the Select tool? I find the modification route starting to get very complicated and messy...

Looking forward to everyone's answers!

Thanks in advance,

Ryan

0 Kudos
12 Replies
RyanBrenner1
Emerging Contributor

Hi Robert,

I was just curious as to the best way to handle the results. I am noticing that when my results come in they are not coming in, in the same order they are being queried. Would I use Dojo/Memory module to handle this? Ie. Save it to memory first then process it with some other information so it remains in the same order?

thanks for the help!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ryan,

   I would have to see some code to be able to see what it going on in your situation.

0 Kudos
RyanBrenner1
Emerging Contributor
queryTask.execute(query);

          // event when complete get the resultant array of features
          
             queryTask.on("complete", lang.hitch(this, function(evt) {
               var featureSet = evt.featureSet;
            console.log('featureSet', featureSet);
            // FeatureSet objects are returned and are set to resultFeatures
            // resultFeatures contains multiple Features
            // The multiple Features contains multiple Attributes which is what we want

            //Performance enhancer - assign featureSet array to a single variable.
               var resultFeatures = featureSet.features;
            console.log('SearchResults: ', resultFeatures);
            console.log('geometryType: ', featureSet.geometryType);



            // customized symbology for the rectangle drawn on the map by the user
            // symbology = red dashdot outline with a pale yellow transparent fill
               var newSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
                 new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
                   new Color([255, 0, 0, 1]), 2), new Color([255, 255, 0, 0.05]));

            // add the graphic to the map
               this._graphicsLayer.add(new Graphic(geometry, newSymbol));

            //*****************************************************************************
// Highlighting the selected features and displaying it on the m        //*****************************************************************************
            // Creating a variable to handle the highlighting symboloy for the geomteryType
            var highlightSymbol;
            switch(featureSet.geometryType) {
              case 'esriGeometryPoint':
              highlightSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 20, null, '#00FFFF');
              break;
              case 'esriGeometryPolyline':
              highlightSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, '#00FFFF', 3);
              break;
              case 'esriGeometryPolygon':
              highlightSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
                new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, '#00FFFF', 2),
                '#e74c3c');
              break;
            }
            //console.log('highlight', highlightSymbol);


            //Loop through each feature returned
            for (var i = 0; i < resultFeatures.length; i++) {
              //Get the current feature from the featureSet.
              //Feature is a graphic
              var graphic = resultFeatures[i].geometry;

              //Add graphic to the map graphics layer.
              this._graphicsLayer.add(new Graphic(graphic, highlightSymbol));
            }

            // this code puts the Class Name and the search result features together into a global array. Need to package for shipping to another script.
            if (FeatureClassName.length > 0) {
              //console.log('j: ', j);
               if (resultFeatures.length > 0) {
                resultFeaturesALL.push({
                  "ClassName": FeatureClassName[j].ClassName,
                  "Feautes": resultFeatures
                });
              }
              j = j + 1;
              //console.log('j: ', j);
            }

            console.log('Array: ', resultFeaturesALL);

         })); // end queryTask
        } // end for loop
0 Kudos