help code

604
1
Jump to solution
05-21-2014 01:07 PM
HectorChapa
Occasional Contributor II
I am having trouble with this code I am trying to auto populate a field from this feature class.
This is what I have so far and is not working.
my events.on('update-end', function is not working.

could someone check it out and tell me what is wrong.

Do I have to use attribute inspector instead if so How do I apply it to this code.

Thanks,


[HTML]
  var events = new FeatureLayer("http://maps.lrgvdc911.org:6080/arcgis/rest/services/Public_Outreach/EVENTS/FeatureServer/0",{
          mode: FeatureLayer.MODE_ONDEMAND,
           outFields: ['EVENT_NAME', 'date','address','city','estattendance','agegroup', 'psap']
        });
       
       events.on('update-end', function(evt){
          var feature = evt.feature;
          feature.attributes.psap = 'hello';
          feature.getLayer().applyEdits(null, [feature], null);
       });
     

        map.addLayers([events]);

        function initEditor(evt) {
          var templateLayers = arrayUtils.map(evt.layers, function(result){
            return result.layer;
          });
          var templatePicker = new TemplatePicker({
            featureLayers: templateLayers,
            grouping: true,
            rows: "auto",
            columns: 1
          }, "draggable");
          templatePicker.startup();
         
        
          
         
         

          var layers = arrayUtils.map(evt.layers, function(result) {
            return { featureLayer: result.layer,
            disableAttributeUpdate: false};
          });
          var settings = {
            map: map,
            templatePicker: templatePicker,
          
            layerInfos: layers,
            toolbarVisible: true,
            createOptions: {
              polylineDrawTools:[ Editor.CREATE_TOOL_FREEHAND_POLYLINE ],
              polygonDrawTools: [ Editor.CREATE_TOOL_FREEHAND_POLYGON,
                Editor.CREATE_TOOL_CIRCLE,
                Editor.CREATE_TOOL_TRIANGLE,
                Editor.CREATE_TOOL_RECTANGLE
              ]
            },
            toolbarOptions: {
              reshapeVisible: true
            }
          };
          
         
          var params = {settings: settings};   
          var myEditor = new Editor(params,'editorDiv');
          //define snapping options
          var symbol = new SimpleMarkerSymbol(
            SimpleMarkerSymbol.STYLE_CROSS,
            15,
            new SimpleLineSymbol(
              SimpleLineSymbol.STYLE_SOLID,
              new Color([255, 0, 0, 0.5]),
              5
            ),
            null
          );
          map.enableSnapping({
            snapPointSymbol: symbol,
            tolerance: 20,
            snapKey: keys.ALT
          });
       
       
          myEditor.startup();
         
         
         
        }[/HTML]
0 Kudos
1 Solution

Accepted Solutions
HectorChapa
Occasional Contributor II
I figure it out this is my answer.


 function initEditor(evt) {           var featureLayer = evt.layers[0].layer;                       dojo.connect(featureLayer,'onBeforeApplyEdits',function(adds,deletes,updates){           dojo.forEach(adds,function(add){                  if(add.attributes['psap'] === null){               add.attributes['psap'] = psap;             }           });         });

View solution in original post

0 Kudos
1 Reply
HectorChapa
Occasional Contributor II
I figure it out this is my answer.


 function initEditor(evt) {           var featureLayer = evt.layers[0].layer;                       dojo.connect(featureLayer,'onBeforeApplyEdits',function(adds,deletes,updates){           dojo.forEach(adds,function(add){                  if(add.attributes['psap'] === null){               add.attributes['psap'] = psap;             }           });         });
0 Kudos