Hi everyoneI am using a dojo datagrid to show records of a table related to the feature layer i am using in my application. This datagrid is binded to the records of the table on selection of one of the feature from the list of features present in a combo box and the map extent is set to the extent of the selected feature. And on the click event of this selected feature infowindow is shown. But the problem occuring is the grid should get refresh whenever a new feature is selected i.e it should only show the records related to selected feature, but instead of it the data in the grid is getting appended. It is showing all the record of previously selected features plus records of currently selected feature. Also when clicking on the very first selected feature infowindow displays right results but on clicking the second or third or any further selected feature from combobox the infowindow does not show results as itdoes not get the map point where i am clicking it take some other random point on the map. But if the function to add records in datagrid is not called the infowindow is working perfectly.I am attaching my code also. Please suggest what additions or changes required in the code. Thanks in advance.dojo.connect(map,"onClick",function(evt)
{
var query = new esri.tasks.Query();
query.geometry = pointToExtent(map,evt.mapPoint,10);
var deferred = electionFeatureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW);
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(evt.mapPoint);
});
function zoomToPst(item)
{
var psname=item.value.toString();
var queryTask1 = new esri.tasks.QueryTask
("http://mrsac.maharashtra.gov.in/ArcGIS/rest/services/MRSACServices/election_9apr/MapServer/0");
var query1 = new esri.tasks.Query();
query1.returnGeometry = true;
query1.outFields = ["OBJECTID"];
query1.where = "District= 'Nagpur' and AC_Name='"+ddl1+"' and PopupInfo='"+psname+"'and PS_Name='"+ddl2+"' ";
queryTask1.execute(query1,function(results2)
{
var id;
var selectedTaxLot;
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SQUARE, new dojo.Color([0,0,0]), 2), new dojo.Color([0,0,0,0.1]));
var features = results2.features;
dojo.forEach (features, function(feature)
{
var g = feature;
g.setSymbol(symbol);
id=feature.attributes.OBJECTID;
});
dojo.forEach(map.graphics.graphics,function(graphic){
if(graphic.attributes)
{
if(graphic.attributes.OBJECTID === id)
{
selectedTaxLot = graphic;
return ;
}
}
});
var taxLotMercator=esri.geometry.geographicToWebMercator(selectedTaxLot.geometry).getExtent().expand(2.0);
map.setExtent(taxLotMercator);
//map.graphics.add(g);
store =new dojo.data.ItemFileReadStore({data:{identifier: "", items :[]}});
grid=dijit.byId("grid");
grid.setStore(store);
//alert("new sr" + newStore);
findRelatedRecords(features);
});
}
function findRelatedRecords(features)
{
alert("rltd rcrds");
var relatedTopsQuery = new esri.tasks.RelationshipQuery();
relatedTopsQuery.outFields = ["*"];
relatedTopsQuery.relationshipId = 0;
var ids = dojo.map(features, function (f) {
return f.attributes.OBJECTID;
});
console.log('ids: ', ids);
relatedTopsQuery.objectIds = ids;
electionFeatureLayer.queryRelatedFeatures(relatedTopsQuery, function(recs)
{
console.log("related recs: ", recs);
for (id in recs)
{
// For each related record, create an item which will correspond to
// a row in the data grid
dojo.forEach(recs[id].features, function (feat) {//alert("push recs");
items.push(feat.attributes);
});
}
//Create data object to be used in store
var data = {
identifier: "OBJECTID", //This field needs to have unique values
label: "OBJECTID", //Name field for display. Not pertinent to a grid but may be used elsewhere.
items: items
};
//Create data store and bind to grid.
store = new dojo.data.ItemFileReadStore({data:data});
grid.setStore(store);
grid.setQuery({OBJECTID: '*'});
//map.graphics.clear();
});
}