fixed grid performance problem - limited length of cell string

This commit is contained in:
SPRINX0\prochazka
2025-06-11 09:30:58 +02:00
parent 871dc90ee4
commit 95f5417761
2 changed files with 7 additions and 3 deletions

View File

@@ -10,6 +10,8 @@ import _omitBy from 'lodash/omitBy';
import { DataEditorTypesBehaviour } from 'dbgate-types';
import isPlainObject from 'lodash/isPlainObject';
export const MAX_GRID_TEXT_LENGTH = 1000; // maximum length of text in grid cell, longer text is truncated
export type EditorDataType =
| 'null'
| 'objectid'
@@ -297,7 +299,9 @@ export function stringifyCellValue(
};
}
}
return { value: highlightSpecialCharacters(value), gridStyle: 'textCellStyle' };
const valueLimited =
value.length > MAX_GRID_TEXT_LENGTH ? value.substring(0, MAX_GRID_TEXT_LENGTH) + '...' : value;
return { value: highlightSpecialCharacters(valueLimited), gridStyle: 'textCellStyle' };
}
default:
return { value: value };

View File

@@ -3,7 +3,7 @@ import { SeriesSizes } from './SeriesSizes';
import type { CellAddress } from './selection';
import type { GridDisplay } from 'dbgate-datalib';
import type Grider from './Grider';
import { isJsonLikeLongString, safeJsonParse } from 'dbgate-tools';
import { isJsonLikeLongString, MAX_GRID_TEXT_LENGTH, safeJsonParse } from 'dbgate-tools';
export function countColumnSizes(grider: Grider, columns, containerWidth, display: GridDisplay) {
// console.log('COUNT SIZES');
@@ -74,7 +74,7 @@ export function countColumnSizes(grider: Grider, columns, containerWidth, displa
else if (value?.$oid) text = `ObjectId("${value.$oid}")`;
else if (value?.$bigint) text = value.$bigint;
else if (isJsonLikeLongString(value) && safeJsonParse(value)) text = '(JSON)';
const width = context.measureText(text).width + 8;
const width = context.measureText(typeof text == 'string' ? text.slice(0, MAX_GRID_TEXT_LENGTH) : text).width + 8;
// console.log('colName', colName, text, width);
columnSizes.putSizeOverride(colIndex, width);
// let colName = this.columns[colIndex].uniquePath;