Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

How do I delete a selected feature from database when it is clicked on in the ArcGIS API for javascript?

share|improve this question

closed as unclear what you're asking by underdark May 23 at 8:35

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

mil gracias por la colaboración, excelente ejemplo. Saludos --- Translation (via Google Translate) thanks for the collaboration, excellent example. regards –  user18510 May 25 '13 at 14:40

2 Answers 2

I don't understand exactly what you're asking, but if you want to handle the delete manually and check whether a graphic is actually selected before trying to delete, you could do something like this:

var myFeatureLayer = new esri.layers.FeatureLayer("",{
    mode: esri.layers.FeatureLayer.MODE_SELECTION,
    outFields: ["*"]

//get the selected graphic from the feature layer, only gets the first graphic, [0]
var targetGraphic = myFeatureLayer .getSelectedFeatures()[0];
//check if there is a selected graphic
if (targetGraphic) {
    //Delete subblock feature
    myFeatureLayer.applyEdits(null, null, [targetGraphic], function (adds, updates, deletes) {
        dojo.byId('infoPane').innerHTML = "Deleted feature successfully, OBJECTID: " + deletes[0].objectId;
    }, dojo.byId('infoPane').innerHTML = "Error when deleting feature");
share|improve this answer
this function can delete feature layer from geo database . can me ask what is subblockEditFeatureLayer mean –  eman Feb 22 '13 at 20:45
Just a name for the feature layer-- you could call it myFeatureLayer. See edit above.. –  awesomo Feb 22 '13 at 20:49

If you mean 'feature' instead of 'feature class', then the default editing widget for the javascript api handles deleting features.

Here is a link to the Esri sample:

share|improve this answer
YES i use already editing widget but i don't able to capture the function of delete in button delete to check if map have graphic or not –  eman Feb 22 '13 at 19:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.