feat: setRowHeight性能优化

This commit is contained in:
liushaozhen 2020-07-23 09:38:08 +08:00
parent 286a4f43be
commit bc5aa63851
6 changed files with 122 additions and 88 deletions

File diff suppressed because one or more lines are too long

192
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -87,6 +87,7 @@ import 'bee-table/build/Table.css';
| [v2.2.8新增]autoSelect | 树型表格勾选时,是否开启子节点的联动 | bool | false | | [v2.2.8新增]autoSelect | 树型表格勾选时,是否开启子节点的联动 | bool | false |
| onPaste | 粘贴的回调函数 | func(event,positon) | - | | onPaste | 粘贴的回调函数 | func(event,positon) | - |
| onBodyScroll | table body 滚动的回调 | func(scrollTop) | - | | onBodyScroll | table body 滚动的回调 | func(scrollTop) | - |
| syncRowHeight | 滚动是否同步高度,关闭此功能有利于提高性能,注:树表和主子表不允许关闭 | true | - |
> 快捷键部分参考示例 (快捷键在table中的简单使用应用) > 快捷键部分参考示例 (快捷键在table中的简单使用应用)

View File

@ -98,7 +98,7 @@ const defaultProps = {
minColumnWidth: 80, minColumnWidth: 80,
locale:{}, locale:{},
syncHover: true, syncHover: true,
setRowHeight:()=>{}, // setRowHeight:()=>{},
setRowParentIndex:()=>{}, setRowParentIndex:()=>{},
tabIndex:'0', tabIndex:'0',
heightConsistent:false, heightConsistent:false,

View File

@ -33,6 +33,7 @@ const propTypes = {
rowDraggAble: PropTypes.bool, rowDraggAble: PropTypes.bool,
onDragRow: PropTypes.func, onDragRow: PropTypes.func,
onDragRowStart: PropTypes.func, onDragRowStart: PropTypes.func,
syncRowHeight:PropTypes.bool
}; };
const defaultProps = { const defaultProps = {
@ -46,6 +47,7 @@ const defaultProps = {
setRowParentIndex:()=>{}, setRowParentIndex:()=>{},
rowDraggAble:false, rowDraggAble:false,
// onDragRow:()=>{} // onDragRow:()=>{}
syncRowHeight:false
}; };
class TableRow extends Component{ class TableRow extends Component{
@ -339,19 +341,20 @@ class TableRow extends Component{
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
const { rowDraggAble } = this.props; const { rowDraggAble,syncRowHeight } = this.props;
if(!this.event){ if(!this.event){
this.event = true; this.event = true;
if(rowDraggAble){ if(rowDraggAble){
this.initEvent(); this.initEvent();
} }
} }
if(this.props.treeType){ if(this.props.treeType){
this.setRowParentIndex(); this.setRowParentIndex();
} }
if(syncRowHeight){
this.setRowHeight() this.setRowHeight()
} }
}
componentWillUnmount() { componentWillUnmount() {
const { record, onDestroy, index,rowDraggAble } = this.props; const { record, onDestroy, index,rowDraggAble } = this.props;