Maddy/newline overrides edit data (#5364)

* formatting it before displaying

* replace with space

* added comments and method to handle the line break space conversion
This commit is contained in:
Maddy
2019-05-06 14:20:08 -07:00
committed by GitHub
parent 56ebbedbfd
commit 7cca1b9f48

View File

@@ -177,10 +177,12 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
this.overrideCellFn = (rowNumber, columnId, value?, data?): string => {
let returnVal = '';
// replace the line breaks with space since the edit text control cannot
// render line breaks and strips them, updating the value.
if (Services.DBCellValue.isDBCellValue(value)) {
returnVal = value.displayValue;
returnVal = this.spacefyLinebreaks(value.displayValue);
} else if (typeof value === 'string') {
returnVal = value;
returnVal = this.spacefyLinebreaks(value);
}
return returnVal;
};
@@ -406,6 +408,13 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
this.refreshGrid();
}
/**
* Replace the line breaks with space.
*/
private spacefyLinebreaks(inputStr: string): string {
return inputStr.replace(/(\r\n|\n|\r)/g, ' ');
}
private refreshGrid(): Thenable<void> {
return new Promise<void>((resolve, reject) => {
const self = this;