feat: 增加 hideDragHandle 参数,隐藏行拖拽把手[#609]
This commit is contained in:
parent
3dd267d7a2
commit
b5eab50b9a
|
@ -115,6 +115,7 @@ var propTypes = {
|
|||
hoverContent: _propTypes2["default"].func,
|
||||
size: _propTypes2["default"].oneOf(['sm', 'md', 'lg']),
|
||||
rowDraggAble: _propTypes2["default"].bool,
|
||||
hideDragHandle: _propTypes2["default"].bool, // 隐藏行拖拽把手
|
||||
onDropRow: _propTypes2["default"].func,
|
||||
onDragRowStart: _propTypes2["default"].func,
|
||||
onBodyScroll: _propTypes2["default"].func,
|
||||
|
@ -168,6 +169,7 @@ var defaultProps = {
|
|||
heightConsistent: false,
|
||||
size: 'md',
|
||||
rowDraggAble: false,
|
||||
hideDragHandle: false,
|
||||
onDropRow: function onDropRow() {},
|
||||
onDragRowStart: function onDragRowStart() {},
|
||||
onBodyScroll: function onBodyScroll() {},
|
||||
|
@ -313,7 +315,8 @@ var Table = function (_Component) {
|
|||
|
||||
var expandedRowKeys = [];
|
||||
var rows = [].concat(_toConsumableArray(props.data));
|
||||
_this.columnManager = new _ColumnManager2["default"](props.columns, props.children, props.originWidth, props.rowDraggAble, props.showRowNum); // 加入props.showRowNum参数
|
||||
var showDragHandle = !props.hideDragHandle && props.rowDraggAble;
|
||||
_this.columnManager = new _ColumnManager2["default"](props.columns, props.children, props.originWidth, showDragHandle, props.showRowNum); // 加入props.showRowNum参数
|
||||
_this.store = (0, _createStore2["default"])({ currentHoverKey: null });
|
||||
_this.firstDid = true;
|
||||
if (props.defaultExpandAllRows) {
|
||||
|
@ -397,6 +400,7 @@ var Table = function (_Component) {
|
|||
|
||||
Table.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
||||
var _props = this.props,
|
||||
hideDragHandle = _props.hideDragHandle,
|
||||
rowDraggAble = _props.rowDraggAble,
|
||||
showRowNum = _props.showRowNum;
|
||||
|
||||
|
@ -411,12 +415,12 @@ var Table = function (_Component) {
|
|||
});
|
||||
}
|
||||
if (nextProps.columns && nextProps.columns !== this.props.columns) {
|
||||
this.columnManager.reset(nextProps.columns, null, showRowNum, rowDraggAble); // 加入this.props.showRowNum参数
|
||||
this.columnManager.reset(nextProps.columns, null, showRowNum, !hideDragHandle && rowDraggAble); // 加入this.props.showRowNum参数
|
||||
if (nextProps.columns.length !== this.props.columns.length && this.refs && this.bodyTable) {
|
||||
this.scrollTop = this.bodyTable.scrollTop;
|
||||
}
|
||||
} else if (nextProps.children !== this.props.children) {
|
||||
this.columnManager.reset(null, nextProps.children, showRowNum, rowDraggAble); // 加入this.props.showRowNum参数
|
||||
this.columnManager.reset(null, nextProps.children, showRowNum, !hideDragHandle && rowDraggAble); // 加入this.props.showRowNum参数
|
||||
}
|
||||
//适配lazyload
|
||||
if (nextProps.scrollTop > -1) {
|
||||
|
|
|
@ -23,7 +23,7 @@ const data = [
|
|||
{ a: "ASVAL_201903120002", b: "小红", c: "女", d: "财务一科", key: "3" }
|
||||
];
|
||||
|
||||
class Demo1 extends Component {
|
||||
class Demo11 extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
@ -59,4 +59,4 @@ class Demo1 extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
export default Demo1;
|
||||
export default Demo11;
|
||||
|
|
|
@ -10,7 +10,7 @@ import React, { Component } from 'react';
|
|||
import Table from '../../src';
|
||||
import dragColumn from '../../src/lib/dragColumn';
|
||||
|
||||
const columns23 = [
|
||||
const columns = [
|
||||
{
|
||||
title: "订单编号",
|
||||
dataIndex: "a",
|
||||
|
@ -38,7 +38,7 @@ const columns23 = [
|
|||
}
|
||||
];
|
||||
|
||||
const data23 = [
|
||||
const data = [
|
||||
{ a: "NU0391001", b: "2019-03-01", c: "xx供应商",d:'Tom', key: "2" },
|
||||
{ a: "NU0391002", b: "2018-11-02", c: "yy供应商",d:'Jack', key: "1" },
|
||||
{ a: "NU0391003", b: "2019-05-03", c: "zz供应商",d:'Jane', key: "3" }
|
||||
|
@ -46,15 +46,15 @@ const data23 = [
|
|||
|
||||
const DragColumnTable = dragColumn(Table);
|
||||
|
||||
class Demo23 extends Component {
|
||||
class Demo30 extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <DragColumnTable
|
||||
columns={columns23}
|
||||
data={data23}
|
||||
columns={columns}
|
||||
data={data}
|
||||
bordered
|
||||
scroll={{y:200}}
|
||||
dragborder={true}
|
||||
|
@ -65,4 +65,4 @@ class Demo23 extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
export default Demo23;
|
||||
export default Demo30;
|
|
@ -30,7 +30,7 @@ const data = [
|
|||
{ a: "ASVAL_201903120007", b: "小杨", c: "女", d: "财务四科", e: "T2", key: "1009" }
|
||||
];
|
||||
|
||||
class Demo1201 extends Component {
|
||||
class Demo38 extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -77,4 +77,4 @@ class Demo1201 extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
export default Demo1201;
|
||||
export default Demo38;
|
||||
|
|
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
11
src/Table.js
11
src/Table.js
|
@ -59,6 +59,7 @@ const propTypes = {
|
|||
hoverContent:PropTypes.func,
|
||||
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
||||
rowDraggAble: PropTypes.bool,
|
||||
hideDragHandle: PropTypes.bool, // 隐藏行拖拽把手
|
||||
onDropRow: PropTypes.func,
|
||||
onDragRowStart: PropTypes.func,
|
||||
onBodyScroll: PropTypes.func,
|
||||
|
@ -103,6 +104,7 @@ const defaultProps = {
|
|||
heightConsistent:false,
|
||||
size: 'md',
|
||||
rowDraggAble:false,
|
||||
hideDragHandle:false,
|
||||
onDropRow: ()=>{},
|
||||
onDragRowStart: ()=>{},
|
||||
onBodyScroll: ()=>{},
|
||||
|
@ -119,7 +121,8 @@ class Table extends Component {
|
|||
super(props);
|
||||
let expandedRowKeys = [];
|
||||
let rows = [...props.data];
|
||||
this.columnManager = new ColumnManager(props.columns, props.children, props.originWidth, props.rowDraggAble, props.showRowNum); // 加入props.showRowNum参数
|
||||
const showDragHandle = !props.hideDragHandle && props.rowDraggAble;
|
||||
this.columnManager = new ColumnManager(props.columns, props.children, props.originWidth, showDragHandle, props.showRowNum); // 加入props.showRowNum参数
|
||||
this.store = createStore({ currentHoverKey: null });
|
||||
this.firstDid = true;
|
||||
if (props.defaultExpandAllRows) {
|
||||
|
@ -203,7 +206,7 @@ class Table extends Component {
|
|||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
let { rowDraggAble, showRowNum } = this.props;
|
||||
let { hideDragHandle, rowDraggAble, showRowNum } = this.props;
|
||||
if ('data' in nextProps) {
|
||||
this.setState({
|
||||
data: nextProps.data,
|
||||
|
@ -215,12 +218,12 @@ class Table extends Component {
|
|||
});
|
||||
}
|
||||
if (nextProps.columns && nextProps.columns !== this.props.columns) {
|
||||
this.columnManager.reset(nextProps.columns, null, showRowNum, rowDraggAble); // 加入this.props.showRowNum参数
|
||||
this.columnManager.reset(nextProps.columns, null, showRowNum, !hideDragHandle && rowDraggAble); // 加入this.props.showRowNum参数
|
||||
if(nextProps.columns.length !== this.props.columns.length && this.refs && this.bodyTable){
|
||||
this.scrollTop = this.bodyTable.scrollTop;
|
||||
}
|
||||
} else if (nextProps.children !== this.props.children) {
|
||||
this.columnManager.reset(null, nextProps.children, showRowNum, rowDraggAble); // 加入this.props.showRowNum参数
|
||||
this.columnManager.reset(null, nextProps.children, showRowNum, !hideDragHandle && rowDraggAble); // 加入this.props.showRowNum参数
|
||||
}
|
||||
//适配lazyload
|
||||
if(nextProps.scrollTop > -1){
|
||||
|
|
Loading…
Reference in New Issue