Has anyone implemented the javascript FeatureTable digit such that selections between it and the underlying featurelayer are synchronized?
Not sure if you've had a chance to look at the Esri example - ArcGIS API for JavaScript Sandbox
There's an event "dgrid-select" to which you can attach, something like:
on(myTable, "dgrid-select", function(evt){
console.log("The dgrid-select event - ", evt);
});
In "evt", you can extract data from the selected row, e.g. evt[0].data.Cmn_Name, or maybe a unique identifier.
From here, I imagine you can apply a selection using that info, maybe something like:
Feature layer with selection | ArcGIS API for JavaScript
You could probably put your selection logic in the "dgrid-select" event - not sure if you need to do multiple selections, though. If so, you can probably work something out!
Thanks, that satisfies a portion of the need. Do you know how one would select a table row using the OBJECTID. Also, do you know how to refresh the featuretable after a new feature is added or an existing one is updated?
Love an answer to your 2nd question if someone knows the answer - how to refresh a featuretable.
For your 1st question this worked for me. (sorry couldn't get it formatted correctly)
//populate the AppTable grid | |
appTable = new FeatureTable({ |
"featureLayer" : AppLayer,
//"readOnly" : false, |
"map" : map
}, 'divApps');
appTable.startup();
on(appTable, "dgrid-select", function(evt){
// fires when a row in the grid is clicked
AppLayer.clearSelection(); | ||||
var EditQuery = new esri.tasks.Query(); | ||||
EditQuery.where = "OBJECTID = " + evt[0].data.OBJECTID; | ||||
EditQuery.outSpatialReference = new esri.SpatialReference({wkid:102100}); | ||||
EditQuery.outFields = ["*"]; | ||||
AppLayer.selectFeatures(EditQuery, esri.layers.FeatureLayer.SELECTION_NEW, function (features) { | ||||
if (features !== undefined && features.length !== 0) { | ||||
//should be only one result returned, so using first array value [0] | ||||
zoomTo(features[0],250); | ||||
} | ||||
else { | ||||
alert("Nothing found.") | ||||
} | ||||
}); |
});
Thanks much. Interesting. The form on(appTable, "dgrid-select", function(evt){ }); is in the example and works for you but does not work for me. I had to use the following: appTable.on("dgrid-select", function(evt){ });
So, has anyone been able to select a row in the FeatureTable based on the OBJECTID of a feature that is selected in the map?
More generally, can anyone expound on the relationship between dGrid and FeatureTable. The latter appears to be an implementation of the former but does not seem to carry with it all of the methods, events and properties of dGrid.
Ken Buja replied and I accidentally deleted. Sorry. The reply was:
Did you include "dojo/on" in the require and "on" in the list of function variables? When using "appTable.on(", you don't need to do that, since it's built into the class, but you do need that when using "on(appTable...)".
Thank you Ken. That was responsible. Rookie error on my part ...
Keith, have you looked at this sample. Not sure if it'd work for a FeatureTable as it uses a dgrid. If nothing else it might give you a hint.