Select to view content in your preferred language

on.once(featureLayer, "before-apply-edits", lang.hitch(this, function (evt) {

1678
4
04-18-2017 06:10 AM
JoseSanchez
Frequent Contributor

Hello everyone,

On  the Edit Widget,  I am looking for a description of the "on.once"  function?

this.editor.templatePicker.on("selection-change", lang.hitch(this, function () {
   var selected = this.editor.templatePicker.getSelected();
   if (selected) {
      var featureLayer = selected.featureLayer;
      on.once(featureLayer, "before-apply-edits", lang.hitch(this, function (evt) {
         if (evt.adds && evt.adds.length > 0) {

Is is part of the FCalss FeatureLayer

FeatureLayer (legacy) | API Reference | ArcGIS API for JavaScript 3.20 

Thanks

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Jose,

   You need to refer to the dojo doc on that:

dojo/on — The Dojo Toolkit - Reference Guide 

0 Kudos
JoseSanchez
Frequent Contributor

Thanks Robert I took a look to the dojo function.

Concerning the event "before-apply-edits" it gets "Fired before edits are applied to the feature layer."

What I don't understand is where in the source code can I check this event BEFORE and AFTER attributes get populated by the editor on the

this.editor.attributeInspector popup window.

In this sample, the code runs BEFORE it gets modified in the attributeInspector, this is why fields are auto-populated.

I am looking for a way to get the values of the feature AFTER they get entered in the  attributeInspector  . For example how can I check that the ProjectID field has its first 4 digits equal to the current year, 2017.

  var featureLayer = selected.featureLayer;
      on.once(featureLayer, "before-apply-edits", lang.hitch(this, function (evt) {
        
 if (evt.adds && evt.adds.length > 0) {

//

// Populate field ProjectID: How to check that the 4 first 4 digits are the Current Year 2017

//

if (evt.adds[0].attributes.hasOwnProperty('ProjectID')) {   

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

I don't have the answer to that.

0 Kudos
JoseSanchez
Frequent Contributor

May be I need to use the event "applyEdits"

//add a save button next to the delete button
     
var saveButton = new Button({ label: "Save", "class": "saveButton"},domConstruct.create("div"));
      domConstruct
.place(saveButton.domNode, attInspector.deleteBtn.domNode, "after");

      saveButton
.on("click", function() {
        updateFeature
.getLayer().applyEdits(null, [updateFeature], null);
     
});

 attInspector.on("attribute-change", function(evt) {
       
//store the updates to apply when the save button is clicked
        updateFeature
.attributes[evt.fieldName] = evt.fieldValue;
     
});

https://developers.arcgis.com/javascript/3/jssamples/ed_attribute_inspector.html

0 Kudos