Example #1
0
 private static void OnRowDeletedEvent(RowChangedEventArgs obj)
 {
     if (_lastEdit != obj.Guid)
     {
         //cancel with dialog
         // Note - feature edits on Hosted and Standard Feature Services cannot be cancelled.
         obj.CancelEdit("Delete Event\nAre you sure", true);
         _lastEdit = obj.Guid;
     }
 }
        private void RowEventHandler(RowChangedEventArgs rc)
        {
            using (var table = rc.Row.GetTable())
            {
                RecordEvent(rc, table);
                //validate flag is set
                //Note, we are validating deletes as well...if that makes sense ;-)
                //if not, change the sample to check the rc.EditType for
                //EditType.Delete and skip...
                if (_validate)
                {
                    //You can use 'rc.Row.HasValueChanged(fieldIndex)` to determine if
                    //a value you need to validate has changed
                    //
                    //call your validation method as needed...
                    //our validate method is a placeholder
                    if (!ValidateTheRow(rc.Row))
                    {
                        //if your validation fails take the appropriate action..
                        //we cancel the edit in this example
                        AddEntry($"*** {_validateMsg}");
                        rc.CancelEdit(_validateMsg);
                        AddEntry("*** edit cancelled");
                        AddEntry("---------------------------------");
                        return;
                    }
                    AddEntry("*** row validated");
                }

                //Cancel flag is set. If you have _failvalidate checked you won't
                //get here - validation will have failed and canceled the edit
                if (_cancelEdit)
                {
                    //cancel the edit
                    rc.CancelEdit($"{rc.EditType} for {table.GetName()} cancelled");
                    AddEntry("*** edit cancelled");
                    AddEntry("---------------------------------");
                }
            }
        }
Example #3
0
        protected void OnRowDeleted(RowChangedEventArgs args)
        {
            var row = args.Row;

            // cancel the delete if the feature is in Police District 5

            var fldIdx = row.FindField("POLICE_DISTRICT");

            if (fldIdx != -1)
            {
                var value = row[fldIdx].ToString();
                if (value == "5")
                {
                    args.CancelEdit();
                }
            }
        }
Example #4
0
        protected void OnRowChanged(RowChangedEventArgs args)
        {
            // RowEvent callbacks are always called on the QueuedTask so there is no need
            // to wrap your code within a QueuedTask.Run lambda.

            var row = args.Row;

            // check for re-entry  (only if row.Store is called)
            if (_currentRowChangedGuid == args.Guid)
            {
                return;
            }

            var fldIdx = row.FindField("POLICE_DISTRICT");

            if (fldIdx != -1)
            {
                //Validate any change to “police district”
                //   cancel the edit if validation on the field fails
                if (row.HasValueChanged(fldIdx))
                {
                    if (FailsValidation(row["POLICE_DISTRICT"].ToString()))
                    {
                        //Cancel edits with invalid “police district” values
                        args.CancelEdit($"Police district {row["POLICE_DISTRICT"]} is invalid");
                    }
                }

                // update the description field
                row["Description"] = "Row Changed";

                //  this update with cause another OnRowChanged event to occur
                //  keep track of the row guid to avoid recursion
                _currentRowChangedGuid = args.Guid;
                row.Store();
                _currentRowChangedGuid = Guid.Empty;
            }
        }