Display feature on mouse over a html table cell

2431
1
Jump to solution
07-19-2012 12:41 PM
SamirGambhir
Occasional Contributor III
Hi,
My application generates a html table dynamically and each selection by the user is added as a new row. I would like the feature to be highlighted on the map when user hovers over the row that lists that feature name in the table. There is definitely something wrong with how I am calling the feature from the feature layer but I am not able to figure this out. Please help.

Here is my code:

HTML:
...
<div dojo-data-type="dijit.form.Form" id="addState" >
            <button data-dojo-type="dijit.form.Button" id="addStateButton" name="addStateButton" data-dojo-props="onClick:function(){addToForm(dijit.byId('selStateA2').displayedValue, dojo.byId('geogTable'));}">Add State(s)<img src="Images/arrow_right.png"  id="imageDown" width="16px" onClick=""></button>
          </div>
...


JavaScript:
...
function addToForm(myValue, myTable){
        rowCount = myTable.rows.length;
        ...
        addRows(myValue, myTable);
        ...
}

function addRows(aValue, aTable){
        var row = aTable.insertRow(rowCount);
        var cell1=row.insertCell(0);
        cell1.innerHTML = aValue;
        if (aTable!=indTable){
          row.onmouseover = function(){displayGeog(aValue);}
        }
        var cell2 = row.insertCell(1);
        cell2.style.width="21px";
        var element2=document.createElement("button");
        element2.style.width="12px";
        element2.style.height="12px";
        element2.style.padding="0px";
        element2.style.border="0px";
        element2.onclick=function(){delRow(aTable,row.rowIndex); return false;};
        var element3=document.createElement("img");
        element3.setAttribute("src", "Images/close_orange2.png");
        element2.appendChild(element3);
        cell2.appendChild(element2);
      }

function displayGeog(disGeog){
        query = new esri.tasks.Query();
        query.outSpatialReference = {"wkid": 102100};
        query.returnGeometry = true;
        query.outFields = ["*"];
        query.where = "1=1";
        if (unitStActiveA==true){
          stateFeatureLayerA.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
          stateFeatureLayerA.setDefinitionExpression("NAME='"+disGeog+"'");
          dojo.connect(stateFeatureLayerA, "onSelectionComplete", function(){
            stateFeatureLayerA.setSelectionSymbol(highlightSymbol);
            mapA.addLayer(stateFeatureLayerA);
            });
          dojo.connect(mapA, 'onLoad', mapA.removeLayer(distFeatureLayerA));
        }
        }

Thanks
Samir
0 Kudos
1 Solution

Accepted Solutions
SamirGambhir
Occasional Contributor III
Please ignore this post. I was selecting features before applying definition expression and symbol. The code works after rearranging these statements.
Thanks
Samir

View solution in original post

0 Kudos
1 Reply
SamirGambhir
Occasional Contributor III
Please ignore this post. I was selecting features before applying definition expression and symbol. The code works after rearranging these statements.
Thanks
Samir
0 Kudos