Possible to edit attribute with a click?

519
1
Jump to solution
04-02-2013 03:33 PM
CharmaleeSandanayake
New Contributor III
I am new to Javascript and I am creating a simple web application to edit the status of road line paint through an iPad JavaScript website. As the city's Public Works field crew completes the line painting job, they would be able to click on and change the status field of each line paint shape to 'Complete' through their iPad.

I have been able to modify the following sample to fit my data: 'Attribute Inspector with one editable field' http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/widget_attributeinspectorpane.html

I found that on the iPad it is cumbersome to click on a feature and then again on the dropdown to modify the feature's attributes.

Is it possible to modify the code so that as soon as the feature is clicked, the status of the line paint layer changes to 'Complete'? A second click on the shape would change the status field back to 'Not Complete'. This way there is no need to go through the dropdown.

Another alternative is having a Complete and Not Complete button. When I select a feature, instead of having a dropdown could I add a button to change the attribute?

The code I have so far is attached and available on this test website too: http://maps.peterborough.ca/trafficlines/editat.html

Any help or input would be appreciated.
0 Kudos
1 Solution

Accepted Solutions
CharmaleeSandanayake
New Contributor III
I was able to edit attributes with a click by adding this code under the onClick event, but it only works for one layer:
 operationalLineLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW, function(features) {             if (features[0].attributes["STATUS2013"] == 'Not Complete') {              //store the current feature               updateFeature = features[0];      updateFeature.attributes["STATUS2013"] = 'Complete';          updateFeature.getLayer().applyEdits(null, [updateFeature], null);              }      else (features[0].attributes["STATUS2013"] == 'Complete') {              //store the current feature               updateFeature = features[0];      updateFeature.attributes["STATUS2013"] = 'Not Complete';          updateFeature.getLayer().applyEdits(null, [updateFeature], null);              }        else {               map.infoWindow.hide();             }           });  


This code only works for my line layer. I am unsure how to run the same selection code for my point and area layers. When I try to copy the code with the other layer names into the onClick event, it only works on the first layer. Not sure how to make all three layers on the map selectable.
To see the test website in action, with only the selection working for the line layer, here is the link: http://maps.peterborough.ca/trafficlines/editwin4.html

Any help would be appreciated.
Thanks,
Charmalee

View solution in original post

0 Kudos
1 Reply
CharmaleeSandanayake
New Contributor III
I was able to edit attributes with a click by adding this code under the onClick event, but it only works for one layer:
 operationalLineLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW, function(features) {             if (features[0].attributes["STATUS2013"] == 'Not Complete') {              //store the current feature               updateFeature = features[0];      updateFeature.attributes["STATUS2013"] = 'Complete';          updateFeature.getLayer().applyEdits(null, [updateFeature], null);              }      else (features[0].attributes["STATUS2013"] == 'Complete') {              //store the current feature               updateFeature = features[0];      updateFeature.attributes["STATUS2013"] = 'Not Complete';          updateFeature.getLayer().applyEdits(null, [updateFeature], null);              }        else {               map.infoWindow.hide();             }           });  


This code only works for my line layer. I am unsure how to run the same selection code for my point and area layers. When I try to copy the code with the other layer names into the onClick event, it only works on the first layer. Not sure how to make all three layers on the map selectable.
To see the test website in action, with only the selection working for the line layer, here is the link: http://maps.peterborough.ca/trafficlines/editwin4.html

Any help would be appreciated.
Thanks,
Charmalee
0 Kudos