Hi to all,
i'm going to customize sample Attribute editing - mobile | ArcGIS API for JavaScript.
What i would like to do is edit attributes of existing features of map. This is at the moment forbidden: now is possible only insert a new feture modifying attributes.
I've tried modifyng this method in this way:
on(appGlobals.citizenRequestLayer, "click", function (event){
//rem this
//appGlobals.map.infoWindow.setFeatures([event.graphic]);
//added
var currentFeature;
var query = new Query();
query.objectIds = [event.graphic.attributes.ID];
appGlobals.citizenRequestLayer.queryFeatures(query, function (featureSet) {
if (featureSet.features.length > 0) {
currentFeature = featureSet.features[0];
}
});
attributeInspector._currentFeature = currentFeature;
$.mobile.changePage("#ui-attributes-page", null, true, true);
});
when i click on exiting point , i view the message "no features selected".
Can anyone help me ?
Thanks
GP
Solved! Go to Solution.
Ok, I finally got it working. The attributeInspector works on the selected features with in the FeatureLayer. so if you change the implementation like below the selected graphic will show up for editing.
var query = new Query(); |
query.objectIds = [event.graphic.attributes.objectid];
appGlobals.citizenRequestLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW).then(function(){
$.mobile.changePage("#ui-attributes-page", null, true, true); |
});
the FeatureLayer queryFeatures is a Deffered method so the set on attributeInspector will be executed before the query is complete you need to change it like below.
appGlobals.citizenRequestLayer.queryFeatures(query, function (featureSet) { if (featureSet.features.length > 0) { currentFeature = featureSet.features[0]; } }).then(function(){ attributeInspector._currentFeature = currentFeature; });
i thejus,
thanks for the suggestion , i've changed code but the result is the same , it doesn't work.
Hi have same message ... no feature selected 😞
here is the code
var currentFeature;
var query = new Query();
query.objectIds = [event.graphic.attributes.ID];
appGlobals.citizenRequestLayer.queryFeatures(query, function (featureSet) {
if (featureSet.features.length > 0) {
currentFeature = featureSet.features[0];
}
}).then(function () {
attributeInspector._currentFeature = currentFeature;
});
$.mobile.changePage("#ui-attributes-page", null, true, true);
many thanks ciao Giorgio
The objectid field for the used citizenRequestLayer is objectid as per Layer: Requests (ID: 0)
you should use
query.objectIds = [event.graphic.attributes.objectid];
Im sorry but nothing ..... doesnt work same result
Ok, I finally got it working. The attributeInspector works on the selected features with in the FeatureLayer. so if you change the implementation like below the selected graphic will show up for editing.
var query = new Query(); |
query.objectIds = [event.graphic.attributes.objectid];
appGlobals.citizenRequestLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW).then(function(){
$.mobile.changePage("#ui-attributes-page", null, true, true); |
});
hi thejus,
thanks a lot , it works 🙂