3.2.0

onCellValidating event not fired if value in cell not changed

We have an XML based Editable table with validation logic for certain columns for Numeric fields.

The grid.onCellValidating() is overwritten to check or numeric values, we also set the Template color to red to indicate user that the value is wrong.

The code is working fine, except for one scenario:
1) Modify the cell value from 12.0 to 12A.0, the cell validated is fired and template color is changed to RED

2) Modify the cell value from 12A.0 to 13.0, the cell is validated, the template color is changed to WHITE

3) But, if you modify the cell value from 12A.0 to 12.0 (the previous value in cell), the onCellValidating method is not fired and the cell retains its RED template color, even though the value is accepted.

I was just curious why the onCellValidating is not fired if there is no change in existing value. Any pointers ?

thank you

grid.onCellValidating = function(text, column, row) { 
            var template = this.getCellTemplate(column, row);           

            //allow only numeric values for number formatted cells
            if ( checkNumericCol(column)  ) {
                if ( checkNumber(text) ) {
                    template.setStyle("color", "red");  
                    return "error";
                } else {        
                    template.setStyle("color", "");  
                }
            }   
     }
Raj Nair
November 2,
The onCellValidating event fires only when the user attempts to change the cell value. If after some editing the cell text is the same as it was initially - the value does not change and there is no validation event. This is by design and I think this is correct behavior - there should not be a validation event if the value does not change.

In your case you may add the style check into the onEditEnded event, which fires always, regardless if there was any change in the cell value.
Alex (ActiveWidgets)
November 6,

This topic is archived.

See also:


Back to support forum