2

I'm using a DxDataGrid in an Angular Application. In this Application I want to enter 4 Dates. Now I need to apply some validation rules, which work fine for each field separatly. The problem is that i need to validate all four fields if one of them changes. For Example: If I enter a endDate which is before the startDate I get the validation error as expected in the endDate-field. If I change the startDate now to some time before the endDate the validation error in the endDate-field remains, because this field is not revalidated.

This is what I have so far:

<dx-data-grid>

  <dxi-column dataField="inPeriodStart" caption="In-Period Start" dataType="date"">
    <dxi-validation-rule reevaluate="true" type="custom" message="Both start and end period has to be specified"
      [validationCallback]="validateStartAndEndInPeriod"></dxi-validation-rule>
    <dxi-validation-rule reevaluate="true" type="custom" message="Start has to be before end." [validationCallback]="validateStartBeforeEnd"></dxi-validation-rule>
    <dxi-validation-rule reevaluate="true" type="custom" message="Either In-Period or For-Period has to be specified."
      [validationCallback]="validateInOrForSpecified"></dxi-validation-rule>
      <dxi-validation-rule type="custom" [validationCallback]="verifyDate" message="In-Period Start must be a valid date"></dxi-validation-rule>
  </dxi-column>


  <dxi-column dataField="inPeriodEnd" caption="In-Period End" dataType="date">
    //same rules
  </dxi-column>


  <dxi-column dataField="forPeriodStart" caption="For-Period Start" dataType="date">
    //same rules
  </dxi-column>

  <dxi-column dataField="forPeriodEnd" caption="For-Period End" dataType="date">
    // same rules
  </dxi-column>
</dx-data-grid>

How do I solve this problem? Thanks for any input

Michael Hanft
  • 21
  • 1
  • 4

1 Answers1

0

It could be probably a wrong syntax( revaluate, try putting in square brackets) in your code.

I have created a below sample and i have placed same validations for first name and last name, please try your use cases and let me know the outcome. https://codesandbox.io/s/0x28kn2v4n

EDIT: When the editing mode is form https://www.devexpress.com/Support/Center/Question/Details/T429488/dxdatagrid-how-to-force-row-validation-if-there-are-no-changes-in-the-form-edit-mode

resolve_promise
  • 435
  • 6
  • 11
  • Thanks, your example works great, but sadly it doesn`t solve my Problem. I need editingmode="form". If I change it in your Demo App it doesn't work anymore. If I change it to batch in my Application it works fine, but the UI needs to be in editmode form. – Michael Hanft Jan 09 '19 at 11:19
  • I didn't know that your datagrid is in form editing mode, but here is some solution that you can try. https://www.devexpress.com/Support/Center/Question/Details/T429488/dxdatagrid-how-to-force-row-validation-if-there-are-no-changes-in-the-form-edit-mode – resolve_promise Jan 11 '19 at 06:50