//add the building Directory files
buildingLayer = new esri.layers.FeatureLayer("http://webgis.uwm.edu/ArcGISUWM/rest/services/CampusJava/MapServer/0",{
mode:esri.layers.FeatureLayer.MODE_SELECTION,
maxAllowableOffset:maxOffset(map,1),
outFields:["NAME","Abbreviati","OBJECTID"]
});
//define a selection symbol
// var highlightSymbol = new esri.symbol.SimpleFillSymbol().setColor( new dojo.Color([50,205,50,.25]));
//buildingLayer.setSelectionSymbol(highlightSymbol);
dojo.connect(buildingLayer,'onLoad',function(layer){
var query = new esri.tasks.Query();
query.where = "1=1";
layer.queryFeatures(query,function(featureSet){
var items = dojo.map(featureSet.features,function(feature){
return feature.attributes;
});
var data = {
identifier:"NAME",
items:items};
store = new dojo.data.ItemFileReadStore({data:data});
grid.setStore(store);
grid.setSortIndex(1,"true"); //sort on the state name
});
});
//modify the grid so only the Building_NAME field is sortable
grid.canSort = function(col){ if(Math.abs(col) == 2) { return true; } else { return false; } };
}
function makeZoomButton(id){
var zBtn = "<div dojoType='dijit.form.Button'><img src='images/zoom2.png'";
zBtn = zBtn + " width='20' height='20'";
zBtn = zBtn + " onClick=\"zoomRow('"+id+"')\"></div>";
return zBtn;
}
function zoomRow(id){
buildingLayer.clearSelection();
var query = new esri.tasks.Query();
query.objectIds = [id];
buildingLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW,function(features){
//zoom to the selected feature
var buildingExtent = features[0].geometry.getExtent().expand(5.0);
map.setExtent(buildingExtent);
});
<div dojotype="dijit.layout.ContentPane" title="Building<br />Directory" selected="false">
<table dojotype="dojox.grid.DataGrid" jsid="grid" id="grid" selectionMode="none">
<thead>
<tr>
<th field="OBJECTID" formatter="makeZoomButton" width="25px">
<img alt="+" src="images/zoom2.png"/>
</th>
<th field="NAME" width="135px">Building</th>
<th field="Abbreviati" width="53px">Abb.</th>
</tr>
</thead>
</table>
</div>