I have a use case where I would like the users to add points and lines to a map, but the attributes should be added via code. I am using an editor widget based on this sample. ArcGIS API for JavaScript Sandbox
Let's say I wanted to add a value 1234 to the "issue_id" attribute when the user created a new feature for the operationsPointLayer in the sample code above? Where in the code would I apply the attribute values?
Thanks in advance!
If I am understanding you right, you want to disable the attributes editing on maps. Try something similar to this:
function initEditor(results) { //only one layer var featureLayer = results[0].layer; /* var templatePicker = new esri.dijit.editing.TemplatePicker({ featureLayers: [featureLayer], rows: 'auto', groupingEnabled:false, columns: 1 },'editorDiv'); templatePicker.startup(); */ var layerInfos = [{ 'featureLayer':featureLayer, 'showAttachments':false, 'showDeleteButton':false, 'fieldInfos':[ {'fieldName':'Name', 'isEditable':false, 'label':'<b> Name:</b>'}, {'fieldName': 'Facility_Type', 'isEditable':true, 'label':'<b>Facility Type:</b>'} ] }]; //define the editor settings var settings = { map: map, /* templatePicker:templatePicker, */ layerInfos:layerInfos }; var params = {settings: settings}; //Create the editor widget var editorWidget = new esri.dijit.editing.Editor(params); editorWidget.startup(); //resize the info window (attribute inspector) map.infoWindow.resize(495,495); }
That is a great start. My use case is a editable map integrated into an existing web application, so I would like the user to just edit the geography and in my code supply some of the attribute values from a parameter elsewhere on the page. So if I wanted to set the value for an attribute called "issue_id" to "234234" for example, would I do that in the
'fieldInfos' : [ ( 'fieldName': "issue_id", value: "234234", 'isEditable' :false) ]
That way I would be setting the issue_id value and not allowing the user to edit it. Thanks kindly.
Have a look at Format Popup Content | Guide | ArcGIS API for JavaScript 3.18 . If your question is answered, please mark the right answer as Correct Answer.
Close but not quite answered. Perhaps this is not possible using this approach. I want not to just format the Popup, but to supply a value. I tried this but it didn't work. There doesn't seem to be a 'value' attribute of a fieldName.
var layerInfos = [{
'featureLayer':featureLayer,
'showAttachments':false,
'showDeleteButton':true,
'fieldInfos':[
{'fieldName':"issue_id", 'isEditable':true, 'label':'<b> IssueId:</b>', 'value': "12313"},
{'fieldName': "issue_name", 'isEditable':true, 'label':'<b>IssueName:</b>'}
]
}];
This thread should help: