Current filter:
                                You should refresh the page.
                                  • I'm showing a dialog using a modal
                                    Since the same component might get shown several times, I'm using DxValidationGroup,reset() to reset validation before showing

                                    Here is my template

                                    <m4u-page [Page]="THIS" WindowWidth="WindowXSmall" WindowHeight="WindowAutoSize" [IsScrollable]="true" *ngIf="Entity && Activity"> <page-content-scroll> <m4u-section Label="{{'titleNewActivity' | RC}}"> <dx-validation-group #validationGroup> <m4u-field [Component]="THIS" Name="ActivityType" Label="{{'lblActivityType' | RC}}"> <dx-select-box [(value)]="Activity.ActivityType" [items]="LIST('ActivityTypes')" #FocusOnMe> </dx-select-box> </m4u-field> <m4u-field [Component]="THIS" Name="Details" Label="{{'lblDetails' | RC}}"> <dx-text-box [(value)]="Activity.Details" > <dx-validator> <dxi-validation-rule type="custom" [validationCallback]="IsNotesDetailsFilled.bind(this)" message="{{'validationActivity' | RC }}"></dxi-validation-rule> </dx-validator> </dx-text-box> </m4u-field> <m4u-field [Component]="THIS" Name="Notes" Label="{{'lblNotes' | RC}}"> <dx-text-area [(value)]="Activity.Notes"> <dx-validator> <dxi-validation-rule type="custom" [validationCallback]="IsNotesDetailsFilled.bind(this)" message="{{'validationActivity' | RC }}"></dxi-validation-rule> </dx-validator> </dx-text-area> </m4u-field> </dx-validation-group> </m4u-section> </page-content-scroll> <page-footer> <m4u-pagebuttons [Page]="THIS" OKText="{{'btnSave' | RC}}" (OnOK)="OnAddActivity()" [ValidationGroup]="validationGroup"> <extra-buttons> <dx-button text="{{'btnSaveAndClose' | RC}}" type="success" (onClick)="Test1(validationGroup)"></dx-button> </extra-buttons> </m4u-pagebuttons> </page-footer> </m4u-page>


                                            return !Utils.IsEmpty(this.Activity.Details) || !Utils.IsEmpty(this.Activity.Notes);  

                                    When I use custom validation rule, the reset() has no effect. I've even added a seprate buttom to test it as u can see

                                    If I change the above validation rules to type="required" and remove ValidationCallback - everything works as expected - validation is being reset properly

                                    I've put a breakpoint inside IsNotesDetailsFilled and I see that it is being called multiple time for some reason when reset() is called - so I assume this is what causing the issue

                                • Artem (DevExpress Support) 09.09.2019

                                  Hi Mike,

                                  Thank you for the detailed description. As far as I understand, validationCallback is executed but the following line returns incorrect results because it is executed multiple times:

                                  return !Utils.IsEmpty(this.Activity.Details) || !Utils.IsEmpty(this.Activity.Notes);

                                  If so, I see that you defined this function for multiple editors:

                                  <dx-text-box [(value)]="Activity.Details" > <dx-validator> <dxi-validation-rule type="custom" [validationCallback]="IsNotesDetailsFilled.bind(this)" message="{{'validationActivity' | RC }}"></dxi-validation-rule> </dx-validator> </dx-text-box> </m4u-field> <m4u-field [Component]="THIS" Name="Notes" Label="{{'lblNotes' | RC}}"> <dx-text-area [(value)]="Activity.Notes"> <dx-validator> <dxi-validation-rule type="custom" [validationCallback]="IsNotesDetailsFilled.bind(this)" message="{{'validationActivity' | RC }}"></dxi-validation-rule> </dx-validator> </dx-text-area>

                                  So, it looks like it's executed for each component separately. You need to make sure that IsNotesDetailsFilled returns true when the reset method is called.

                                  We look forward to your results.
                                  If it doesn't help, create an example for detailed research. You can use one of our demos to demonstrate your scenario. Extract the demo into a stand-alone example using the"Copy To CodeSandBox" button and modify it using the "Save"button to apply changes. Then, post the updated link here for further examination. Or, you can use our project template as a starting point. We'll do our best to put you on the right track.

                                • Mike Postel 09.11.2019
                                  1. Ive used the same function twice because the idea here is to make a validation that makes sure at least 1 out of those 2 fields is filled in
                                  2. It is called much more then 2 times, something like 10 times I think
                                  3. IsNotesDetailsFilled returns false when reset is called - I call the reset function when popup is shown and fields are empty. In my understanding, reset() is supposed to mark the field as valid regardless of it's actual validity - until the user will change the field or .validate() will be called.

                                1 Solution

                                Creation Date Importance Sort by

                                Hi Mike,
                                Additional calls may be performed if Angular bindings are changed. The reset method calls the validationCallback function for CustomRule in any framework. It's up to you to decide what result should be returned. However, the problem is that there is no option to distinguish this execution from a regular validation check. You need to implement a global variable if it's necessary to distinguish such actions.
                                I also found the TextBox validation clearing in Angular 4 thread where we discussed how to accomplish this task.
                                Let me know if this approach helps.

                                Show all comments
                                • Mike Postel 09.16.2019

                                  I'm not sure I understand why it calls the validationCallback at all? Why not just to reset the validation state regardless of anything? Because according to what you are saying, there is no difference between callling .reset() and calling .validate()

                                • Artem (DevExpress Support) 09.17.2019

                                  Hi Mike,
                                  The validationCallback function is called because the reset method clears the current editor value. This logic makes the validation execute again. So, you need to create a custom flag to determine why the validationCallback function was executed.

                                • Mike Postel 09.21.2019

                                  OK.. I think maybe I wasn't clear in what I'm trying to acheive here
                                  I dont want to reset the value of the editor - its empty anyway (in this case, but may be filled in in other)
                                  I just want to reset the validation state without touching the actual value
                                  I find it strange this cannot be done separately from setting the value.
                                  Usage of flags & such is problematic since this is just one out of many places where I need this
                                  I'm just looking for a simple method that will mark all elements inside a validation group as valid, regardless of anything..

                                • Artem (DevExpress Support) 09.23.2019

                                  Hi Mike,
                                  Your task is clear. The problem is that we don't have a built-in method for this purpose as the reset\resetGroup method always clears current values. As a result, validationCallback is executed That's why I suggested using a custom variable to determine why the validationCallback function is called.
                                  As an alternative solution, you can manually change isValid and validationError for each editor.
                                  Let us know if you need further clarification on this.

                                • Mike Postel 09.26.2019

                                  OK.. this one might be a better approach
                                  How do I enumerate all relevant widgets within a validation group? Does it have some method/property that returns the list of relevant widgets I can build upon?

                                • Artem (DevExpress Support) 09.27.2019

                                  Hi Mike,
                                  There is no specific method at the ValidationGroup level. However, I see two possible solutions:

                                  1. You can manually collect widget instances using onInitialized
                                  2. You can use Angular ViewChildren to obtain editors in the Angular-way: What are all the valid selectors for ViewChild and ContentChild?