I've built upon the Find Task example given in the ArcGIS API for JavaScript:http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/find_map.htmlWhere not only does the Find Task return Values in a map service but also made it possible to click through examples that will return that geometry's values map extent.However, the Find Task returns polygons from the map service that have the same Value, e.g. one road with 5 polygons will return 5 values, when I'm only interested in that one road.For aesthetic reasons, I want it to return a collapsed tree where its children are all the results and the root is one result returned from the Find Task.This is where dojo's TreeGrid comes in.I've looked at the syntax and structure of the dojo TreeGrid, and I'm at a loss how to plug in the Find Task into returning results in a TreeGrid.BTW, the code snippet that I've written that returns the map extent is built upon this:NOTE: the 4th (0-index) value is dataForGrid.push([result.layerName, result.foundFieldName, result.value, result.geometry, result.feature.geometry.getExtent()]);
dojo.connect(grid, 'onRowClick', function(evt) {
var kannar_xmin = new Array();
var kannar_ymin = new Array();
var kannar_xmax = new Array();
var kannar_ymax = new Array();
var extt;
if (grid.selection) {
// Get all selected items from the Grid:
var items = grid.selection.getSelected();
if (items.length) {
// Iterate through the list of selected items.
// The current item is available in the variable
// "selectedItem" within the following function:
dojo.forEach(items, function(selectedItem) {
if (selectedItem !== null) {
extt = grid.store.getValues(selectedItem, "4")[0];
// use the initial selected extent
kannar_xmin = [grid.store.getValues(selectedItem, "4")[0].xmin];
kannar_ymin = [grid.store.getValues(selectedItem, "4")[0].ymin];
kannar_xmax = [grid.store.getValues(selectedItem, "4")[0].xmax];
kannar_ymax = [grid.store.getValues(selectedItem, "4")[0].ymax];
} // end if
//examine for lowest and highest extent within 10km
for (var k=0; k<grid._by_idx.length; k++) {
if (
( grid.store.getValues(selectedItem, "2")[0] === grid._by_idx.item[2][0]) &&
(10000 > (Math.abs(grid.store.getValues(selectedItem, "4")[0].xmin - grid._by_idx.item[4][0].xmin))) &&
(10000 > (Math.abs(grid.store.getValues(selectedItem, "4")[0].ymin - grid._by_idx.item[4][0].ymin))) &&
(10000 > (Math.abs(grid.store.getValues(selectedItem, "4")[0].xmax - grid._by_idx.item[4][0].xmax))) &&
(10000 > (Math.abs(grid.store.getValues(selectedItem, "4")[0].ymax - grid._by_idx.item[4][0].ymax))) )
{
for (var i=0; i<(grid._by_idx.length); i++) {
if (
(10000 > (Math.abs(grid._by_idx.item[4][0].xmin - grid._by_idx.item[4][0].xmin))) &&
(10000 > (Math.abs(grid._by_idx.item[4][0].ymin - grid._by_idx.item[4][0].ymin))) &&
(10000 > (Math.abs(grid._by_idx.item[4][0].xmax - grid._by_idx.item[4][0].xmax))) &&
(10000 > (Math.abs(grid._by_idx.item[4][0].ymax - grid._by_idx.item[4][0].ymax))) )
{
//build temporary 'kannar_' array for checking lowest and highest value out from the IF conditions
kannar_xmin.push(grid._by_idx.item[4][0].xmin);
kannar_ymin.push(grid._by_idx.item[4][0].ymin);
kannar_xmax.push(grid._by_idx.item[4][0].xmax);
kannar_ymax.push(grid._by_idx.item[4][0].ymax);
}
}
}
}
// examine xmin
extt.xmin = kannar_xmin.min();
// examine ymin
extt.ymin = kannar_ymin.min();
// examine xmax
extt.xmax = kannar_xmax.max();
// examine ymax
extt.ymax = kannar_ymax.max();
// if extt is not defined, then use the selected value as extent
if (extt.xmin === undefined)
{
extt = grid.store.getValues(selectedItem, "4")[0];
alert("xmin: " + extt.xmin + " , _partwise: " + extt._partwise);
}
}); // end forEach
} // end if
} //end if onClick
map.setExtent(extt.expand(2));
});
the min and max function calls are:
// function for finding highest value of an array with a for loop
Array.prototype.max = function() {
var max = this[0];
var len = this.length;
for (var j = 1; j < len; j++) if (this > max) max = this;
return max;
}
// function for finding lowest value of an array with a for loop
Array.prototype.min = function() {
var min = this[0];
var len = this.length;
for (var j = 1; j < len; j++) if (this < min) min = this;
return min;
}
If I have to submit further explanation on my issue, please let me know.