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

                                    [HTML]
                                    <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>

                                     

                                     Test1(g)  
                                        {  
                                            g.instance.reset();  
                                            this.DetectChanges();  
                                            debugger;  
                                        }  
                                      
                                      
                                     IsNotesDetailsFilled()  
                                        {  
                                            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:

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

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

                                  [HTML]
                                  <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.

                                • 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.