Select to view content in your preferred language

Open Info Window on grid RowClick

2212
3
09-25-2014 08:12 AM
RichardMoussopo
Frequent Contributor

I have the code below that shows the info window on map click. I would like to call the same function in the gridRowClick event.

function identifyPOI(evt) {

    var measureMode = dojo.query(".esriButton .dijitButtonNode").some(function (node, index, arr) {

        if (node.childNodes[0].checked) {

            //at least one of the measure tools is active so disable identify 

            return true;

        }

    });

    if (!measureMode) {

        var identify = new esri.tasks.IdentifyTask(".../MapServer");

        var identifyParams = new esri.tasks.IdentifyParameters();

        identifyParams.geometry = evt.mapPoint;

        identifyParams.mapExtent = map.extent;

        identifyParams.returnGeometry = true;

        identifyParams.tolerance = 3;

        map.infoWindow.clearFeatures();

       

        //Define a good infoTemplate

        var infoTemplateUtilities = new esri.InfoTemplate();

       

        infoTemplateUtilities.setTitle("FacilityID: <br/> <b>${Facility Identifier}</b>");

        infoTemplateUtilities.setContent("Open file:  <b> <a href='Documentation/${MAPREF}.pdf' target='_blank'> ${MAPREF} </a>  </b><br/>" +

                                  "Install Date: <b>${Install Date} </b><br/>" +

                                  "Material: <b>${Material}</b><br/>" +

                                  "Diameter: <b>${Diameter}</b> <br/>" +

                                  "Status: <b>${Status}</b> <br/>" +

                                  "Last Update Date: <b>${Last Update Date}</b> <br/>" +

                                  "Water Type: <b>${Water Type}</b> <br/>" +

                                  "Lenght(ft): <b>${SHAPE_Length}</b> <br/>");

        try {

            identify.execute(identifyParams, function (results) {

                map.infoWindow.setFeatures(dojo.map(results, function (result) {

                    var feature = result.feature;

                    feature.setInfoTemplate(infoTemplateUtilities);

                    return feature;

                }));

                map.infoWindow.show(evt.mapPoint);

            });

        }

        catch (ex) {

            alert(ex.toString());

        }

     

    }

};

function onRowClickHandler(evt) {

    var clickedUtilityId = grid.getItem(evt.rowIndex).OBJECTID;

    var selectedUtility;

   

    dojo.forEach(map.graphics.graphics, function (graphic) {

        if ((graphic.attributes) && graphic.attributes.OBJECTID === clickedUtilityId) {

            selectedUtility = graphic.geometry;

            return;

        }

    });

   

    var thePoly = selectedUtility;

    var theExtent = thePoly.getExtent();

    map.setExtent(theExtent, true);

    //and display the infoWindow

    var utilityLenght = thePoly.paths[0].length;

    if(utilityLenght % 2 !=0){

       utilityLenght = utilityLenght - 1;

       var pointXY = thePoly.paths[0][(utilityLenght / 2)];

       var infoPoint = new esri.geometry.Point(pointXY[0], pointXY[1], new esri.spatialReference({ wkid: 102723 }));

       try{

       

           identifyPOI(evt.infoPoint); //<====  here is where I am not sure...

        }

       catch (ex) {

           alert(ex.toString());

       }

     

       

    }

   

};

the image below is the final result I am trying to achieve.

RowClick_Info_Window.PNG

0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor

I think the simplest thing to do would be to rewrite your identifyPOI function so it takes a point instead of an event, since you don't use any other part of the event.
.


function identifyPOI(point) {


You'll just have to make sure you pass in the point on the map click. If that isn't possible, you could do something like this


function identifyPOI(evt) {  


    openInfoWindow(evt.mapPoint);


}





function openInfoWindow(point) {


    var measureMode = dojo.query(".esriButton .dijitButtonNode").some(function (node, index, arr) {  


        if (node.childNodes[0].checked) {  


            //at least one of the measure tools is active so disable identify    


            return true;  


        }  


    });  


  


    if (!measureMode) {


        var identify = new esri.tasks.IdentifyTask(".../MapServer");  


        var identifyParams = new esri.tasks.IdentifyParameters();  


        identifyParams.geometry = evt.mapPoint;  


        identifyParams.mapExtent = map.extent;  


        identifyParams.returnGeometry = true;  


        identifyParams.tolerance = 3;  


  


  


        map.infoWindow.clearFeatures();  


          


        //Define a good infoTemplate  


        var infoTemplateUtilities = new esri.InfoTemplate();  


          


        infoTemplateUtilities.setTitle("FacilityID: <br/> <b>${Facility Identifier}</b>");  


        infoTemplateUtilities.setContent("Open file:  <b> <a href='Documentation/${MAPREF}.pdf' target='_blank'> ${MAPREF} </a>  </b><br/>" +  


                                  "Install Date: <b>${Install Date} </b><br/>" +  


                                  "Material: <b>${Material}</b><br/>" +  


                                  "Diameter: <b>${Diameter}</b> <br/>" +  


                                  "Status: <b>${Status}</b> <br/>" +  


                                  "Last Update Date: <b>${Last Update Date}</b> <br/>" +  


                                  "Water Type: <b>${Water Type}</b> <br/>" +  


                                  "Lenght(ft): <b>${SHAPE_Length}</b> <br/>");  


  


  


        try {  


            identify.execute(identifyParams, function (results) {  


  


  


                map.infoWindow.setFeatures(dojo.map(results, function (result) {  


                    var feature = result.feature;  


                    feature.setInfoTemplate(infoTemplateUtilities);  


                    return feature;  


                }));  


                map.infoWindow.show(point);  


            });  


  


  


        }  


        catch (ex) {  


            alert(ex.toString());  


        }  


        


    }  


  


}  

and inf the onRowClickHandler function, use

  1.        try{ 
  2.          
  3.       openInfoWindow(infoPoint); //<====  here is where I am not sure...  
  4.         } 
  5.        catch (ex) { 
  6.            alert(ex.toString()); 
  7.        } 
0 Kudos
RichardMoussopo
Frequent Contributor

Thank you Ken for replying...

I tried what you said and it did not work. I also tried to change

identifyParams.geometry = point;   line 16 above

but still nothing.

0 Kudos
TracySchloss
Honored Contributor

Did you get this figured out yet?  It seems like a post that even a week old gets lost down the list.

0 Kudos