Skip to content

Commit

Permalink
[feat] add test case and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
qili.taoqili committed Mar 12, 2019
1 parent 37ef425 commit 7b70277
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ $ npm start
|defaultEditable |boolean |optional |false | 10.4.16 |默认开启行编辑模式|
|useListActionBar |boolean |optional |false | 10.5.0 |新版listActionBar开关,actionBar配置,详细[见此](#actionbar)|
|getTooltipContainer |function() |optional |null | 10.5.2 |单元格编辑状态下,tooltip位置可控
|columnResizeable |boolean |optional |false | 10.5.3 |表格列可拖拽
|columnResizeable |boolean |optional |true | 10.5.3 |表格列可拖拽


### 折叠展开专用
Expand Down
36 changes: 22 additions & 14 deletions src/Header/HeaderCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,32 @@ class HeaderCell extends React.Component {
}
return null;
}
onDrag = (e, node, column) => {
const changeWidth = node.lastX - this.state.lastColumnWidth;
this.props.handleColumnResize(e, changeWidth, column, node.node)
onDrag = (e, data, column) => {
const changeWidth = data.lastX - this.state.lastColumnWidth;
// console.log(data.lastX, this.state.lastColumnWidth, changeWidth)

this.props.handleColumnResize(e, changeWidth, column, data.node)
this.setState({
lastColumnWidth: node.lastX
lastColumnWidth: data.lastX
})
}

needResize(column) {
const { columnResizeable, last } = this.props
return columnResizeable
&& column.type !== 'treeIcon'
&& column.type !== 'checkboxSelector'
&& column.type !== 'radioSelector'
// && !column.fixed
&& !column.rightFixed
&& !column.hidden
&& !last
}

render() {
const me = this;
const {
renderModel, prefixCls, column, index, hasGroup, last, tablePrefixCls, columnResizeable
renderModel, prefixCls, column, index, hasGroup, last, tablePrefixCls
} = me.props;
const rowSelectorInTreeMode = (['checkboxSelector', 'radioSelector'].indexOf(column.type) !== -1)
&& (renderModel === 'tree');
Expand Down Expand Up @@ -321,19 +335,13 @@ class HeaderCell extends React.Component {
{me.renderFilterIcon(column)}
<MessageIcon message={column.message} prefixCls={`${prefixCls}-msg`} />
{
columnResizeable
&& column.type !== 'treeIcon'
&& column.type !== 'checkboxSelector'
&& column.type !== 'radioSelector'
// && !column.fixed
&& !column.rightFixed
&& !column.hidden
&& !last

this.needResize(column)
? <Draggable
axis="x"
onDrag={(e, dragNode) => {this.onDrag(e, dragNode, column)}}
>
<div style={{height: '50px', right: '0', width: '10px', background: 'rgba(0,0,0,0)', cursor: 'ew-resize', position: 'absolute', zIndex: 99}} />
<span className={`${tablePrefixCls}-cell-resize-icon`} style={{width: '10px', right: '0'}} />
</Draggable>
: null }
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const defaultProps = {
showColumnPickerCheckAll: false,
defaultEditable: false,
getTooltipContainer: null,
columnResizeable: false,
columnResizeable: true,
};

// http://facebook.github.io/react/docs/reusable-components.html
Expand Down
8 changes: 8 additions & 0 deletions src/style/Header.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
margin-left: 4px;
vertical-align: -1px;
}
.@{__tablePrefixCls}-cell-resize-icon {
display: inline-block;
height: 50px;
background: rgba(0,0,0,0);
cursor: ew-resize;
position: absolute;
z-index: 99;
}

.@{__tablePrefixCls}-header-item-filter-dropdown {
box-shadow: @box-shadow-1;
Expand Down

0 comments on commit 7b70277

Please sign in to comment.