Solved! Go to Solution.
.dgrid-grid { height: auto; width: 700px; }
function queryFeaturesbyShape(userGeometry){ map.graphics.clear(); eezFeatureLayer.clearSelection(); var clearGrid_bg = dojo.byId('resultsSelectGrid').innerHTML = ""; var clearGridTable = dojo.byId('selectGridTable').innerHTML = ""; var query = new esri.tasks.Query(); query.outSpatialReference = { wkid: 102100 }; query.returnGeometry = true; query.outFields = ["*"]; query.geometry = userGeometry; query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS; query.returnGeometry = true; fLayers = setFeatureLayers(); var bg2010Vis = fLayers.indexOf('eezFeatureLayer'); if (fLayers.indexOf('eezFeatureLayer') >= 0) { eezFeatureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW); var selectHandler = dojo.connect(eezFeatureLayer, "onSelectionComplete", populateBgGrid); } } function populateBgGrid (results) { var data = []; if (dGridStacked) { dGridStacked.refresh(); } if (dGridTable) { dGridTable.refresh(); } data = dojo.map(results, function(feature){ return { 'censusid': feature.attributes['DE_MOEEZ.DEAPPMOEEZGISD.blockGroupCalculations.BlockGroupName'], 'population': formatThousandSeparator(feature.attributes['DE_MOEEZ.DEAPPMOEEZGISD.blockGroupCalculations.Population']), 'unemployment': formatPercentage(feature.attributes['DE_MOEEZ.DEAPPMOEEZGISD.blockGroupCalculations.Unemployment']), 'countypoverty': formatPercentage(feature.attributes['DE_MOEEZ.DEAPPMOEEZGISD.blockGroupCalculations.CountyPoverty']), 'statepoverty': formatPercentage(feature.attributes['DE_MOEEZ.DEAPPMOEEZGISD.blockGroupCalculations.StatePoverty']), 'zonecrosspct': formatOverlap(feature.attributes['DE_MOEEZ.DEAPPMOEEZGISD.blockGroupCalculations.ZoneCrossPct']) }; }); dGridStacked = new dgrid.Grid({ renderRow: renderRowFunction, showHeader: true }, "resultsSelectGrid"); dGridStacked.renderArray(data); dGridStacked.sort('censusid'); dGridTable = new dgrid.Grid({ id:'dGridTable', showHeader: true, bufferRows: Infinity, columns: { "censusid": "Block Group", "population": "Population", "unemployment": "Unemployment", "countypoverty": "County Poverty", "statepoverty": "State Poverty", "zonecrosspct": "Percent Overlap" } }, "selectGridTable"); dGridTable.renderArray(data); dGridTable.sort('censusid'); dGridStacked.on('.dgrid-row:click', function(event){ eezFeatureLayer.clearSelection(); var row = dGridStacked.row(event); var query = new esri.tasks.Query(); var queryId = [row.data.censusid]; query.where = "SD_GIS.OGI.CENSUS_BLOCKGRP_2010.GEOID10 = '" + queryId + "'"; query.returnGeometry = true; query.outFields = ["*"]; var deferred = eezFeatureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW, function(features){ if (features.length > 0) { var feature = features[0]; var graphic = new esri.Graphic(feature.geometry, redFillSymbol); map.graphics.add(graphic); } else { console.log("No records by that ID"); } }); deferred.addErrback(function(error){ console.log("Grid Select Error = " + error); }); }); } //data coming from the query needs to be formatted to look right in the grid function formatThousandSeparator(checkNumber){ checkNumber += ''; x = checkNumber.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } function formatPercentage (checkNumber) { var test1= checkNumber.toFixed(3); var test2 = test1 * 100; var formatPct = test2.toFixed(1) + "%"; return formatPct; } function formatOverlap (checkNumber) { var test1 = checkNumber.toFixed(1); var formatPct = test1 + "%"; return formatPct; } function renderRowFunction (obj,options) { // var template = '<div class="title">${0}</div><div class="subtitle"><div class="details">${1}</div> <div class="details"> ${2}<br> ${3}</div>'; var template = '<div class="title">${0}</div><div class="details">Population: ${1}</div> <div class="details">Unemployment: ${2}</div><div class="details">County Poverty: ${3}</div><div class="details"> State Poverty: ${4}</div><div class="details"> Overlap Pct: ${5}</div>'; return dojo.create("div",{ innerHTML : dojo.string.substitute(template,[obj.censusid,obj.population,obj.unemployment,obj.countypoverty,obj.statepoverty,obj.zonecrosspct]) }); }
.dgrid-grid { height: auto; width: 700px; }
I know this thread is old but I ran into this exact problem and grid.resize(); fixed it for me.