I am building a search tool which has a text box ,a dropdown and a submit button.The drop down would essentially contain attribute field names and on submit i have code as bellow
findParams = new esri.tasks.FindParameters();
findParams.returnGeometry = true;
findParams.layerIds = [5];
findParams.searchFields = dojo.byId("drop_down").value;
findParams.outSpatialReference = map.spatialReference;
function doFind() {
//Set the search text to the value in the box
findParams.searchText = dojo.byId("Risk_Score").value;
findTask.execute(findParams, showResults);
}
function showResults(results) {
//This function works with an array of FindResult that the task returns
map.graphics.clear();
//var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98, 194, 204]), 2), new dojo.Color([98, 194, 204, 0.5]));
var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color([0, 0, 0]), 3);
//create array of attributes
var items = dojo.map(results, function (result) {
var graphic = result.feature;
graphic.setSymbol(symbol);
map.graphics.add(graphic);
return result.feature.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 });
var grid = dijit.byId('grid');
grid.setStore(store);
//Zoom back to the initial map extent
map.setExtent(startExtent);
}
does this idea work?? and i have problem in loading field names to the drop down.Any help on this would be great. Thanks in advance.-Pramod