Hi Ankit,
My validator:
export async function createDateRangeValidation(
headerText: string,
minDate: Date,
maxDate: Date
): Promise<any> {
return {
type: 'date',
comparisonOperator: 'between',
value1: minDate,
value2: maxDate,
errorMessage: await getTranslation(
'Common',
'validation.invalidDateFormat',
{
name: headerText
}
),
errorStyle: 'stop',
highlightStyle: {
type: 'dogEar',
color: 'red',
position: 'topLeft'
},
ignoreBlank: false,
inCellDropdown: false,
errorTitle: '',
inputMessage: '',
inputTitle: '',
showErrorMessage: true,
showInputMessage: false
}
}
I want to validate a date range from the start to the end of the current month. If the date column is enabled, it is required. This validator works as expected.
The issue begins when I have some disabled cells. I disable a cell by modifying the openDateTimePicker command to execute as follows:
let oldOpenDateTimeCmd =
GC.Spread.Sheets.Commands.openDateTimePicker.execute
sheet.bind(
GC.Spread.Sheets.Events.EditStarting,
function (sender: any, args: any, e: any) {
if (disabledRows.has(args.row)) {
args.cancel = true
}
}
)
Then my object has isDisabled = true and date = undefined. SpreadJS displays 0001/01/01 (why not blank?) => I added a custom style with the backColor and foreColor set to the same color to hide it. The validator is triggered in this disabled cell in my object and displays an error (of course).
I don’t want to validate empty data cells like this, so I updated my validator with ignoreBlank = true.
Another issue appears: enabled cells can use the Delete button to clear their value. With ignoreBlank, the validator no longer validates this cell.
This behavior is generally acceptable, but it is not correct in my case.
Please advise on how to disable specific date cells in a column, not validate those cells, and validate other date cells in the same column as required and within the range. Any workaround is accepted.
Best Regards,
Lucas