支持用户自定义展开和关闭图标

This commit is contained in:
izbz wh 2019-05-08 23:02:28 +08:00
parent 0b24e76178
commit be75c6e9e8
10 changed files with 4880 additions and 19579 deletions

3
dist/demo.css vendored
View File

@ -209,6 +209,9 @@
.u-table th.text-right,
.u-table td.text-right {
text-align: right; }
.u-table th .expand-icon-con,
.u-table td .expand-icon-con {
cursor: pointer; }
.u-table-sm td {
padding: 8px 8px; }
.u-table-lg td {

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

23977
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

@ -85,7 +85,8 @@ import 'bee-table/build/Table.css';
| headerDisplayInRow | 设置表头的内容显示一行,超出显示省略号 | bool |
| bodyDisplayInRow | 设置表体的内容显示一行,超出显示省略号 | bool |
| rowDraggAble | 是否增加行交换顺序功能 | boolean| false
|expandedIcon|嵌套表格场景中展开子表时的展开图标|||
|collapsedIcon|嵌套表格场景中关闭子表时的关闭图标|||
> 快捷键部分参考示例 (快捷键在table中的简单使用应用)
*注意: data参数中的key值必需否则会导致部分功能出现问题建议使用唯一的值如id*

View File

@ -20,16 +20,20 @@ class ExpandIcon extends Component{
return !shallowequal(nextProps, this.props);
}
render() {
const { expandable, clsPrefix, onExpand, needIndentSpaced, expanded, record, isHiddenExpandIcon } = this.props;
const { expandable, clsPrefix, onExpand, needIndentSpaced, expanded, record, isHiddenExpandIcon,expandedIcon,collapsedIcon } = this.props;
if (expandable && !isHiddenExpandIcon) {
const expandClassName = expanded ? 'expanded' : 'collapsed';
return (
<Icon
let currentIcon = <Icon
className={`${clsPrefix}-expand-icon ${clsPrefix}-${expandClassName}`}
type={expanded ? 'uf-triangle-down' : 'uf-triangle-right'}
onClick={(e) => onExpand(!expanded, record, e)}
/>
);
/>;
if(expanded && expandedIcon){
currentIcon = expandedIcon;
}else if(!expanded && collapsedIcon){
currentIcon = collapsedIcon;
}
return (<span onClick={(e) => onExpand(!expanded, record, e)} className='expand-icon-con'>{currentIcon}</span>);
} else if (needIndentSpaced || isHiddenExpandIcon) {
return <span className={`${clsPrefix}-expand-icon ${clsPrefix}-spaced`} />;
}

View File

@ -702,6 +702,8 @@ class Table extends Component {
onDragRow={this.onDragRow}
contentTable={this.contentTable}
tableUid = {this.tableUid}
expandedIcon={props.expandedIcon}
collapsedIcon={props.collapsedIcon}
/>
);
this.treeRowIndex++;

View File

@ -117,6 +117,9 @@ $icon-color:#505F79;
&.text-right{
text-align: right;
}
.expand-icon-con{
cursor: pointer;
}
}
&-sm {
td {

View File

@ -353,6 +353,7 @@ class TableRow extends Component{
clsPrefix, columns, record, height, visible, index,
expandIconColumnIndex, expandIconAsCell, expanded, expandRowByClick,rowDraggAble,
expandable, onExpand, needIndentSpaced, indent, indentSize,isHiddenExpandIcon,fixed,bodyDisplayInRow
,expandedIcon,collapsedIcon
} = this.props;
let showSum = false;
let { className } = this.props;
@ -373,6 +374,8 @@ class TableRow extends Component{
needIndentSpaced={needIndentSpaced}
expanded={expanded}
record={record}
expandedIcon={expandedIcon}
collapsedIcon={collapsedIcon}
isHiddenExpandIcon={isHiddenExpandIcon}
/>
);