test: add default _disableColumnAndRowSizeRound config

This commit is contained in:
Rui-Sun 2024-05-13 19:41:25 +08:00
parent eb5a9638be
commit d337ce23c5
4 changed files with 200 additions and 2 deletions

View File

@ -906,6 +906,14 @@ export const menus = [
{
path: 'unit-test-demo',
name: 'pivotTable-size-legend'
},
{
path: 'unit-test-demo',
name: 'unit-listTable-sort'
},
{
path: 'unit-test-demo',
name: 'unit-listTable-frozen'
}
]
},

View File

@ -0,0 +1,96 @@
import * as VTable from '../../src';
import records from './marketsales.json';
const ListTable = VTable.ListTable;
const CONTAINER_ID = 'vTable';
export function createTable() {
const containerDom: HTMLElement = document.getElementById(CONTAINER_ID) as HTMLElement;
// containerDom.style.position = 'relative';
containerDom.style.width = '1000px';
containerDom.style.height = '800px';
const columns = [
{
field: '订单 ID',
caption: '订单 ID',
sort: true,
width: 'auto',
description: '这是订单的描述信息',
style: {
fontFamily: 'Arial',
fontSize: 14
}
},
{
field: '订单日期',
caption: '订单日期'
},
{
field: '发货日期',
caption: '发货日期'
},
{
field: '客户名称',
caption: '客户名称',
style: {
padding: [10, 0, 10, 60]
}
},
{
field: '邮寄方式',
caption: '邮寄方式'
},
{
field: '省/自治区',
caption: '省/自治区'
},
{
field: '产品名称',
caption: '产品名称'
},
{
field: '类别',
caption: '类别'
},
{
field: '子类别',
caption: '子类别'
},
{
field: '销售额',
caption: '销售额'
},
{
field: '数量',
caption: '数量'
},
{
field: '折扣',
caption: '折扣'
},
{
field: '利润',
caption: '利润'
}
];
const option = {
columns,
defaultColWidth: 150,
allowFrozenColCount: 5,
frozenColCount: 2
};
option.container = containerDom;
option.records = records;
const tableInstance = new ListTable(option);
window.tableInstance = tableInstance;
setTimeout(() => {
console.log(tableInstance.frozenColCount);
}, 3000);
setTimeout(() => {
tableInstance.frozenColCount = 4;
console.log(tableInstance.frozenColCount);
tableInstance.release();
}, 6000);
}

View File

@ -0,0 +1,94 @@
import * as VTable from '../../src';
import records from './marketsales.json';
const ListTable = VTable.ListTable;
const CONTAINER_ID = 'vTable';
export function createTable() {
const containerDom: HTMLElement = document.getElementById(CONTAINER_ID) as HTMLElement;
// containerDom.style.position = 'relative';
containerDom.style.width = '1000px';
containerDom.style.height = '800px';
const columns = [
{
field: '订单 ID',
caption: '订单 ID',
sort: true,
width: 'auto',
description: '这是订单的描述信息',
style: {
fontFamily: 'Arial',
fontSize: 14
}
},
{
field: '订单日期',
caption: '订单日期'
},
{
field: '发货日期',
caption: '发货日期'
},
{
field: '客户名称',
caption: '客户名称',
style: {
padding: [10, 0, 10, 60]
}
},
{
field: '邮寄方式',
caption: '邮寄方式'
},
{
field: '省/自治区',
caption: '省/自治区'
},
{
field: '产品名称',
caption: '产品名称'
},
{
field: '类别',
caption: '类别'
},
{
field: '子类别',
caption: '子类别'
},
{
field: '销售额',
caption: '销售额'
},
{
field: '数量',
caption: '数量'
},
{
field: '折扣',
caption: '折扣'
},
{
field: '利润',
caption: '利润'
}
];
const option = {
columns,
defaultColWidth: 150,
allowFrozenColCount: 5,
sortState: {
field: '订单 ID',
order: 'desc'
}
};
option.container = containerDom;
option.records = records;
const tableInstance = new ListTable(option);
window.tableInstance = tableInstance;
setTimeout(() => {
console.log(tableInstance.getCellValue(6, 3));
}, 3000);
}

View File

@ -1011,7 +1011,7 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
// : this.internalProps.defaultRowHeight)
// );
if (isValid(this.rowHeightsMap.get(row))) {
if (this.options._disableColumnAndRowSizeRound) {
if (this.options._disableColumnAndRowSizeRound ?? true) {
const height = this.rowHeightsMap.get(row);
let heightRange;
if (row < this.frozenRowCount) {
@ -1129,7 +1129,7 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
h += this.getRowHeight(i);
}
} else {
if (this.options._disableColumnAndRowSizeRound) {
if (this.options._disableColumnAndRowSizeRound ?? true) {
for (let i = startRow; i <= endRow; i++) {
h += this.getRowHeight(i);
}