ag-gridag-grid-valuesetterag-grid-validation

AG Grid: Better way for validation row - valueSetter?


Is there a better way to validate a row in ag-grid than with valueSetter?

I can achieve the validation with that but I am not sure, if there is a better way.

https://www.ag-grid.com/javascript-grid-value-setters/#properties-for-setters-and-parsers

I want to validate two fields in the row. DateFrom and DateUntil (they are not allow to be null and DateFrom must be lower than DateUntil).


Solution

  • There are two ways of possible validation handling:

    First: via ValueSetter function

    and

    Second: via custom cellEditor component

    I suggest that it would be better to split the logic between custom components, but as you said you need to validate two cell-values between themselves.

    On this case from UI perspective you could try to combine them inside one cell and it would be easily to work with values via one component only.