When I enter a value, it works fine. But, once the cell is non-blank, I can’t seem to delete the value (without the delete key, or backspace), without it staying red in color (being invalid). How can I allow users to delete the content of a date cell?
If you want to allow the user to delete the date value, but don’t mind it still being highlighted as invalid, use the allowInvalid option. What it does, is allowing to pass invalid values (and an empty value is not a proper date, so it is invalid), but the validator still works as it should, so it marks the cell red.
If you’d like, however to make it possible to delete the date-typed cell’s content without it being marked as invalid, but still use the validation on non-empty cells, you will have to make a simple custom validator.
For example:
var customDateValidator = function(value, callback) {
if (value === '') {
callback(true);
} else {
Handsontable.DateValidator.call(this, value, callback);
}
};
and applying it in the Handsontable initial settings in the validator property:
Ok, thanks; that seems to work functionally, but its giving me an error with my TypeScript compilation (it doesn’t know what Handsontable.DataValidator is). Is there a newer Typescript file available then this one?