kmacleod

quick q: how to display ALL fields in esri.dijit.Popup

Discussion created by kmacleod on Apr 22, 2013
Latest reply on May 14, 2013 by nilsbabel
Hi all,

I want to display all attributes for all fields in an esri.dijit.Popup window.

I remember seeing this somewhere but can not find it again. I want to accomplish the same thing the following code would do in a regular infoWindow:

var infoTemplate = new esri.InfoTemplate("${name}", "${*}");

But with a Popup Dijit. Anyone know the syntax? Thanks!





Below is the entire code / details for why/what I am trying to accomplish. I want to convert the code below to a Popup dijit and put a 'title' in as a Description since it overwrites the title because it shows multiple coincident features.

       var infoTemplate = new esri.dijit.PopupTemplate({
                            title: "",
                            description: feature.attributes.layerName,
                            fieldInfos: [
                            { fieldName: "${*}", visible: true, label: "{*}" }
                            ]
                        });




I want to make that work in the identify widget:
//// Identify Widget ////
        var identifyParams;
        var tasks;
        var clickPoint;

            //var popup = new esri.dijit.Popup({ fillSymbol: new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]))}, dojo.create("div"));


        dojo.connect(map, 'onLoad', function () {
            //setup generic identify parameters 
            identifyParams = new esri.tasks.IdentifyParameters();
            identifyParams.tolerance = 5;
            identifyParams.returnGeometry = true;
            identifyParams.layerIds = MYDYNAMICLAYER.visibleLayers;
            identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;

            dojo.connect(map, 'onClick', doIdentify);
        });





        dojo.connect(map, 'onLayersAddResult', setupIdentify);


        function setupIdentify(results) {
            //loop through operational layers and add identify task for each. 
            tasks = dojo.map(results, function (result) {
                return new esri.tasks.IdentifyTask(result.layer.url);
            });


        }
        function doIdentify(evt) {

            map.infoWindow.hide();
            clickPoint = evt.mapPoint;

            identifyParams.geometry = evt.mapPoint;
            identifyParams.mapExtent = map.extent;
            identifyParams.width = map.width;
            identifyParams.height = map.height;
            identifyParams.layerIds = MYDYNAMICLAYER.visibleLayers;
            identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;

            var deferreds = dojo.map(tasks, function (task) {
                return task.execute(identifyParams);
            });
            var dlist = new dojo.DeferredList(deferreds);
            dlist.then(handleQueryResults);

        }
        function handleQueryResults(results) {

            var features = [];
            dojo.forEach(results, function (result) {
                // for a simplified test let's just display all the attributes in the popup 
                if (result[1].length > 0) {
                    dojo.forEach(result[1], function (r) {
                        var feature = r.feature;
                        console.log(feature);
                        feature.attributes.layerName = r.layerName;


                        var infoTemplate = new esri.InfoTemplate("${name}", "${*}");
                        

                        feature.setInfoTemplate(infoTemplate);
                        features.push(feature);

                    });
                }

            });
            map.infoWindow.setFeatures(features);
            map.infoWindow.show(clickPoint);

        }


        //// ^^^  Identify Widget ////

Outcomes