Hello,
I am trying to check some custom validation when a value is adjusted on a TelerikForm. And I am using
EditContext.OnFieldChanged += HandleFieldChanged;
But the value is still the old value, it looks like the TelerikInputBase is firing the notification before the change is actually applied.
private protected void TriggerChange(T value) { if (this.ValidateOn == ValidationEvent.Change) this.CascadedEditContext?.NotifyFieldChanged(this.FieldIdentifier); this.OnChange.InvokeAsync((object) value); }
Is there a better way to be doing this?
I do not want to have to add the validation check on every input OnChange.
I have also tried OnFormUpdate with the same issue, this is the function I am using where EditContext still has the old values
protected async Task OnFormUpdate(FormUpdateEventArgs args) { if (!IsUpdating) { IsUpdating = true; DataHasChanged = true; var type = args.Model.GetType(); var property = type.GetProperty(args.FieldName); if (property != null) { if (property.GetCustomAttributes(typeof(SkipMessageCheckAttribute), true).FirstOrDefault() is not SkipMessageCheckAttribute) { await CheckMessagesAsync(); } } IsUpdating = false; } DataIsValid = !EditContext.GetValidationMessages().Any() && Messages.All(m => m.Priority != PageMessagePriority.Error); }
Thanks,
Matt