mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Fix for null shift-tab/focus (#8937)
* Added fix for null * removed space * formatting and optimization
This commit is contained in:
@@ -172,9 +172,16 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
let returnVal = '';
|
let returnVal = '';
|
||||||
// replace the line breaks with space since the edit text control cannot
|
// replace the line breaks with space since the edit text control cannot
|
||||||
// render line breaks and strips them, updating the value.
|
// render line breaks and strips them, updating the value.
|
||||||
if (Services.DBCellValue.isDBCellValue(value) && !value.isNull) {
|
/* tslint:disable:no-null-keyword */
|
||||||
|
let valueMissing = value === undefined || value === null || (Services.DBCellValue.isDBCellValue(value) && value.isNull);
|
||||||
|
if (valueMissing) {
|
||||||
|
/* tslint:disable:no-null-keyword */
|
||||||
|
returnVal = null;
|
||||||
|
}
|
||||||
|
else if (Services.DBCellValue.isDBCellValue(value)) {
|
||||||
returnVal = this.spacefyLinebreaks(value.displayValue);
|
returnVal = this.spacefyLinebreaks(value.displayValue);
|
||||||
} else if (typeof value === 'string') {
|
}
|
||||||
|
else if (typeof value === 'string') {
|
||||||
returnVal = this.spacefyLinebreaks(value);
|
returnVal = this.spacefyLinebreaks(value);
|
||||||
}
|
}
|
||||||
return returnVal;
|
return returnVal;
|
||||||
@@ -366,7 +373,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
id: columnIndex,
|
id: columnIndex,
|
||||||
name: escape(c.columnName),
|
name: escape(c.columnName),
|
||||||
field: columnIndex,
|
field: columnIndex,
|
||||||
formatter: Services.textFormatter,
|
formatter: this.getColumnFormatter,
|
||||||
isEditable: c.isUpdatable
|
isEditable: c.isUpdatable
|
||||||
};
|
};
|
||||||
}))
|
}))
|
||||||
@@ -725,4 +732,29 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Formatter for Column*/
|
||||||
|
private getColumnFormatter(row: number | undefined, cell: any | undefined, value: any, columnDef: any | undefined, dataContext: any | undefined): string {
|
||||||
|
let valueToDisplay = '';
|
||||||
|
let cellClasses = 'grid-cell-value-container';
|
||||||
|
/* tslint:disable:no-null-keyword */
|
||||||
|
let valueMissing = value === undefined || value === null || (Services.DBCellValue.isDBCellValue(value) && value.isNull);
|
||||||
|
if (valueMissing) {
|
||||||
|
valueToDisplay = 'NULL';
|
||||||
|
cellClasses += ' missing-value';
|
||||||
|
}
|
||||||
|
else if (Services.DBCellValue.isDBCellValue(value)) {
|
||||||
|
valueToDisplay = (value.displayValue + '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||||
|
valueToDisplay = escape(valueToDisplay.length > 250 ? valueToDisplay.slice(0, 250) + '...' : valueToDisplay);
|
||||||
|
}
|
||||||
|
else if (typeof value === 'string' || (value && value.text)) {
|
||||||
|
if (value.text) {
|
||||||
|
valueToDisplay = value.text;
|
||||||
|
} else {
|
||||||
|
valueToDisplay = value;
|
||||||
|
}
|
||||||
|
valueToDisplay = escape(valueToDisplay.length > 250 ? valueToDisplay.slice(0, 250) + '...' : valueToDisplay);
|
||||||
|
}
|
||||||
|
return '<span title="' + valueToDisplay + '" class="' + cellClasses + '">' + valueToDisplay + '</span>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user