-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix group cell in vtable-export #2487
- Loading branch information
Showing
6 changed files
with
126 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import * as VTable from '@visactor/vtable'; | ||
const CONTAINER_ID = 'vTable'; | ||
const generatePersons = count => { | ||
return Array.from(new Array(count)).map((_, i) => ({ | ||
id: i + 1, | ||
email1: `${i + 1}@xxx.com`, | ||
name: `小明${i + 1}`, | ||
lastName: '王', | ||
date1: '2022年9月1日', | ||
tel: '000-0000-0000', | ||
sex: i % 2 === 0 ? 'boy' : 'girl', | ||
work: i % 2 === 0 ? 'back-end engineer' : 'front-end engineer', | ||
city: 'beijing' | ||
})); | ||
}; | ||
|
||
export function createTable() { | ||
const records = generatePersons(100); | ||
const columns: VTable.ColumnsDefine = [ | ||
{ | ||
field: '', | ||
title: '行号', | ||
width: 80, | ||
fieldFormat(data, col, row, table) { | ||
return row - 1; | ||
} | ||
}, | ||
{ | ||
field: 'id', | ||
title: 'ID', | ||
width: '1%', | ||
minWidth: 200, | ||
sort: true | ||
}, | ||
{ | ||
field: 'email1', | ||
title: 'email', | ||
width: 200, | ||
sort: true | ||
}, | ||
{ | ||
title: 'full name', | ||
columns: [ | ||
{ | ||
field: 'name', | ||
title: 'First Name', | ||
width: 200 | ||
}, | ||
{ | ||
field: 'name', | ||
title: 'Last Name', | ||
width: 200 | ||
} | ||
] | ||
}, | ||
{ | ||
field: 'date1', | ||
title: 'birthday', | ||
width: 200 | ||
}, | ||
{ | ||
field: 'sex', | ||
title: 'sex', | ||
width: 100 | ||
}, | ||
{ | ||
field: 'tel', | ||
title: 'telephone', | ||
width: 150 | ||
}, | ||
{ | ||
field: 'work', | ||
title: 'job', | ||
width: 200 | ||
}, | ||
{ | ||
field: 'city', | ||
title: 'city', | ||
width: 150 | ||
} | ||
]; | ||
const option = { | ||
container: document.getElementById(CONTAINER_ID), | ||
records, | ||
columns, | ||
tooltip: { | ||
isShowOverflowTextTooltip: true | ||
}, | ||
groupBy: 'sex' | ||
// frozenColCount: 1, | ||
// bottomFrozenRowCount: 2, | ||
// rightFrozenColCount: 2, | ||
// overscrollBehavior: 'none' | ||
// autoWrapText: true, | ||
// heightMode: 'autoHeight', | ||
// widthMode: 'adaptive' | ||
}; | ||
const tableInstance = new VTable.ListTable(option); | ||
window.tableInstance = tableInstance; | ||
// tableInstance.on('sort_click', args => { | ||
// tableInstance.updateSortState( | ||
// { | ||
// field: args.field, | ||
// order: Date.now() % 3 === 0 ? 'desc' : Date.now() % 3 === 1 ? 'asc' : 'normal' | ||
// }, | ||
// false | ||
// ); | ||
// return false; //return false代表不执行内部排序逻辑 | ||
// }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters