mirror of
https://github.com/VisActor/VTable
synced 2024-11-22 18:57:38 +00:00
fix: fix estimate position in updateAutoRow() #2494
This commit is contained in:
parent
b63a63993f
commit
2bebb95a66
@ -0,0 +1,10 @@
|
||||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@visactor/vtable",
|
||||
"comment": "fix: fix estimate position in updateAutoRow() #2494",
|
||||
"type": "none"
|
||||
}
|
||||
],
|
||||
"packageName": "@visactor/vtable"
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import * as VTable from '../../src';
|
||||
import { bindDebugTool } from '../../src/scenegraph/debug-tool';
|
||||
import { AggregationType } from '../../src/ts-types';
|
||||
const CONTAINER_ID = 'vTable';
|
||||
const generatePersons = count => {
|
||||
@ -156,7 +157,7 @@ export function createTable() {
|
||||
isShowOverflowTextTooltip: true
|
||||
},
|
||||
frozenColCount: 1,
|
||||
// bottomFrozenRowCount: 2,
|
||||
bottomFrozenRowCount: 2,
|
||||
rightFrozenColCount: 1,
|
||||
overscrollBehavior: 'none',
|
||||
autoWrapText: true,
|
||||
@ -221,25 +222,29 @@ export function createTable() {
|
||||
// widthMode: 'adaptive'
|
||||
};
|
||||
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
|
||||
// tableInstance.deleteRecords([0]);
|
||||
tableInstance.updateRecords(
|
||||
[
|
||||
{
|
||||
id: 10,
|
||||
email1: '10@xxx.com',
|
||||
name: '小明10',
|
||||
lastName: '王',
|
||||
date1: '2022年9月1日',
|
||||
tel: '000-0000-0000',
|
||||
sex: 'girl',
|
||||
work: 'front-end engineer10',
|
||||
city: 'beijing',
|
||||
salary: 60
|
||||
}
|
||||
],
|
||||
[0]
|
||||
);
|
||||
tableInstance.deleteRecords([0]);
|
||||
// tableInstance.updateRecords(
|
||||
// [
|
||||
// {
|
||||
// id: 10,
|
||||
// email1: '10@xxx.com',
|
||||
// name: '小明10',
|
||||
// lastName: '王',
|
||||
// date1: '2022年9月1日',
|
||||
// tel: '000-0000-0000',
|
||||
// sex: 'girl',
|
||||
// work: 'front-end engineer10',
|
||||
// city: 'beijing',
|
||||
// salary: 60
|
||||
// }
|
||||
// ],
|
||||
// [0]
|
||||
// );
|
||||
window.tableInstance = tableInstance;
|
||||
|
||||
bindDebugTool(tableInstance.scenegraph.stage, {
|
||||
customGrapicKeys: ['col', 'row']
|
||||
});
|
||||
tableInstance.on('change_cell_value', arg => {
|
||||
console.log(arg);
|
||||
});
|
||||
|
@ -34,7 +34,7 @@ export function updateAutoRow(
|
||||
}
|
||||
} else {
|
||||
// 估计位置
|
||||
y = table.getRowsHeight(table.frozenRowCount, cellGroup.row - 1);
|
||||
y = getEstimatePosition(cellGroup.row, table);
|
||||
}
|
||||
if (isValid(y)) {
|
||||
cellGroup.setAttribute('y', y);
|
||||
@ -61,7 +61,7 @@ export function updateAutoRow(
|
||||
}
|
||||
} else {
|
||||
// 估计位置
|
||||
y = table.getRowsHeight(table.frozenRowCount, cellGroup.row - 1);
|
||||
y = getEstimatePosition(cellGroup.row, table);
|
||||
// console.log('估计位置', table.getRowsHeight(table.frozenRowCount, cellGroup.row));
|
||||
}
|
||||
if (isValid(y)) {
|
||||
@ -94,3 +94,17 @@ export function updateAutoRow(
|
||||
// y = child.attribute.y + child.attribute.height;
|
||||
// });
|
||||
}
|
||||
|
||||
// 获取预估位置
|
||||
function getEstimatePosition(row: number, table: BaseTableAPI) {
|
||||
let y;
|
||||
if (row < table.frozenRowCount) {
|
||||
y = table.getRowsHeight(0, row - 1);
|
||||
} else if (row >= table.rowCount - table.bottomFrozenRowCount) {
|
||||
y = table.getRowsHeight(table.rowCount - table.bottomFrozenRowCount, row - 1);
|
||||
} else {
|
||||
y = table.getRowsHeight(table.frozenRowCount, row - 1);
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user