我在Angular应用程序中使用DxDataGrid。在此应用程序中,我要输入4个日期。现在,我需要应用一些验证规则,这些规则对于每个字段都可以独立工作。 问题是,如果其中之一发生更改,我需要验证所有四个字段。例如:如果我输入一个在startDate之前的endDate,我将在endDate字段中得到预期的验证错误。如果我现在将 startDate 更改为 endDate 之前的某个时间,则endDate字段中的验证错误仍然存在,因为该字段未重新验证。
这是我到目前为止所拥有的:
<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>
如何解决此问题?感谢您的输入
答案 0 :(得分:0)
代码中的语法可能不正确(重新评估,请尝试放在方括号中)。
我创建了一个下面的示例,并且对名字和姓氏进行了相同的验证,请尝试使用用例,并让我知道结果。 https://codesandbox.io/s/0x28kn2v4n