Hello Moudud,
When you apply the custom culture to set the shortDatePattern, the editing format follows the current culture, using shortDatePattern.
However, if any style formatter is applied to the cell, the cell display controlled by style formatter, and the cell editing text controlled by editing format. but that format is not fixed, it will change according to the last inputting text, and autoFomatter strategy. This behavior is same as that of Microsoft Excel.
If you want the editor format to be same as that of the cell display format, you could use the following workaround:
var oldCmd = GC.Spread.Sheets.Commands.editCell.execute;
GC.Spread.Sheets.Commands.editCell.execute = function (context, options: any, isUndo) {
var sheet = context.getSheetFromName(options.sheetName);
// Get the Formatter or set your own formatter
var formatter = sheet.getFormatter(options.row, options.col, GC.Spread.Sheets.SheetArea.viewport);
if (options.editingFormatter && formatter) {
options.editingFormatter = new GC.Spread.Formatter.GeneralFormatter(formatter);
}
return oldCmd.apply(this, arguments);
}
var oldSetEditorValueFn = GC.Spread.Sheets.CellTypes.Text.prototype.setEditorValue;
GC.Spread.Sheets.CellTypes.Text.prototype.setEditorValue = function (
editor,
value,
context
) {
var sheet = context.sheet,
row = context.row,
column = context.col;
var cellValue = sheet.getValue(row, column);
// Get the formatter or set your own formatter
var formatter = sheet.getFormatter(row, column);
if (cellValue && formatter) {
value = new GC.Spread.Formatter.GeneralFormatter(formatter).format(cellValue);
oldSetEditorValueFn.call(this, editor, value, context);
} else {
oldSetEditorValueFn.apply(this, arguments);
}
};
If you examine the above code snippet, I am getting the current cell formatter (var formatter) , you could replace it with another formatter that you want to display.
Sample: https://jscodemine.grapecity.com/share/FoakIhU6j0qvsEOpnsYJfA/?defaultOpen={“OpenedFileName”:[“/index.html”,“/package.json”,“/src/app.component.ts”],“ActiveFile”:“/src/app.component.ts”}
You may also refer to the following Forum case that discusses the similar issue: https://www.grapecity.com/forums/spreadjs/date-cell-formatter-return-to-default-eng-after-value-confirmation
I hope that clarifies your question. Please let me know if you still face any issues.
Regards,
Ankit