feat: onDropRow增加参数targetIndex
This commit is contained in:
parent
54f77ec52e
commit
17bf7b9c49
|
@ -239,11 +239,15 @@ var Table = function (_Component) {
|
|||
targetIndex = i;
|
||||
}
|
||||
});
|
||||
data = _this.swapArray(data, currentIndex, targetIndex);
|
||||
_this.props.onDropRow && _this.props.onDropRow(data, record);
|
||||
_this.setState({
|
||||
data: data
|
||||
});
|
||||
if (currentIndex > -1) {
|
||||
data = _this.swapArray(data, currentIndex, targetIndex);
|
||||
_this.props.onDropRow && _this.props.onDropRow(data, record, targetIndex);
|
||||
_this.setState({
|
||||
data: data
|
||||
});
|
||||
} else {
|
||||
_this.props.onDropRow && _this.props.onDropRow(data, record, targetIndex);
|
||||
}
|
||||
};
|
||||
|
||||
_this.swapArray = function (arr, index1, index2) {
|
||||
|
@ -1556,6 +1560,9 @@ var Table = function (_Component) {
|
|||
this.lastScrollTop = e.target.scrollTop;
|
||||
if (handleScrollY) {
|
||||
(0, _utils.debounce)(handleScrollY(this.lastScrollTop, this.treeType, onBodyScroll), 300);
|
||||
} else {
|
||||
//滚动回调
|
||||
onBodyScroll(this.lastScrollTop);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ const data = [ ...new Array(10000) ].map((e, i) => {
|
|||
})
|
||||
|
||||
|
||||
class Demo32 extends Component {
|
||||
class Demo43 extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -87,4 +87,4 @@ class Demo32 extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
export default Demo32;
|
||||
export default Demo43;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
14
src/Table.js
14
src/Table.js
|
@ -664,11 +664,15 @@ class Table extends Component {
|
|||
targetIndex = i;
|
||||
}
|
||||
});
|
||||
data = this.swapArray(data,currentIndex,targetIndex);
|
||||
this.props.onDropRow && this.props.onDropRow(data,record);
|
||||
this.setState({
|
||||
data,
|
||||
});
|
||||
if(currentIndex > -1) {
|
||||
data = this.swapArray(data,currentIndex,targetIndex);
|
||||
this.props.onDropRow && this.props.onDropRow(data,record,targetIndex);
|
||||
this.setState({
|
||||
data,
|
||||
});
|
||||
} else {
|
||||
this.props.onDropRow && this.props.onDropRow(data,record,targetIndex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 数组元素交换位置
|
||||
|
|
Loading…
Reference in New Issue