fix: fix originCol/Row in custom computation

This commit is contained in:
Rui-Sun 2024-11-15 14:42:29 +08:00
parent 7c471456f8
commit 3cc65b46bc
4 changed files with 17 additions and 9 deletions

View File

@ -31,7 +31,7 @@ export const CustomLayout: React.FC<CustomLayoutProps> = (props: PropsWithChildr
// customLayout function for vtable
const createGraphic: ICustomLayoutFuc = useCallback(
args => {
const key = `${(args as any).originCol}-${(args as any).originRow}`;
const key = `${args.originCol ?? args.col}-${args.originRow ?? args.row}`;
let group;
if (container.current.has(key)) {
const currentContainer = container.current.get(key);

View File

@ -456,21 +456,24 @@ function computeCustomRenderWidth(col: number, row: number, table: BaseTableAPI)
let width = 0;
let renderDefault = false;
let enableCellPadding = false;
let cellRange;
if (
table.isHeader(col, row) ||
(table.getBodyColumnDefine(col, row) as TextColumnDefine)?.mergeCell ||
table.hasCustomMerge()
) {
const cellRange = table.getCellRange(col, row);
cellRange = table.getCellRange(col, row);
spanCol = cellRange.end.col - cellRange.start.col + 1;
}
const arg = {
col,
row,
col: cellRange?.start.col ?? col,
row: cellRange?.start.row ?? row,
dataValue: table.getCellOriginValue(col, row),
value: table.getCellValue(col, row) || '',
rect: getCellRect(col, row, table),
table
table,
originCol: col,
originRow: row
};
if (customLayout === 'react-custom-layout') {
// customLayout = table._reactCreateGraphic;

View File

@ -549,21 +549,24 @@ function computeCustomRenderHeight(col: number, row: number, table: BaseTableAPI
let height = 0;
let renderDefault = false;
let enableCellPadding = false;
let cellRange;
if (
table.isHeader(col, row) ||
(table.getBodyColumnDefine(col, row) as TextColumnDefine)?.mergeCell ||
table.hasCustomMerge()
) {
const cellRange = table.getCellRange(col, row);
cellRange = table.getCellRange(col, row);
spanRow = cellRange.end.row - cellRange.start.row + 1;
}
const arg = {
col,
row,
col: cellRange?.start.col ?? col,
row: cellRange?.start.row ?? row,
dataValue: table.getCellOriginValue(col, row),
value: table.getCellValue(col, row) || '',
rect: getCellRect(col, row, table),
table
table,
originCol: col,
originRow: row
};
if (customLayout === 'react-custom-layout') {
// customLayout = table._reactCreateGraphic;

View File

@ -11,6 +11,8 @@ export interface CustomRenderFunctionArg {
/**原始值 */
dataValue: FieldData;
rect?: RectProps;
originCol?: number;
originRow?: number;
}
interface baseElement {
elementKey?: string;