mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 22:39:34 +08:00
parent
a5585bff77
commit
6b0a3e129c
@ -749,8 +749,8 @@ export default class Table extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { style, className, ...restProps } = this.props;
|
||||
const data = this.getCurrentPageData();
|
||||
const { style, className, rowKey, ...restProps } = this.props;
|
||||
let data = this.getCurrentPageData();
|
||||
let columns = this.renderRowSelection();
|
||||
const expandIconAsCell = this.props.expandedRowRender && this.props.expandIconAsCell !== false;
|
||||
const locale = this.getLocale();
|
||||
@ -767,27 +767,37 @@ export default class Table extends React.Component {
|
||||
return newColumn;
|
||||
});
|
||||
let emptyText;
|
||||
let emptyClass = '';
|
||||
let emptyRowKey;
|
||||
|
||||
if (!data || data.length === 0) {
|
||||
emptyText = (
|
||||
<div className="ant-table-placeholder">
|
||||
{locale.emptyText}
|
||||
</div>
|
||||
);
|
||||
emptyClass = 'ant-table-empty';
|
||||
columns.forEach((column, index) => {
|
||||
columns[index].render = () => ({
|
||||
children: !index ? emptyText : null,
|
||||
props: {
|
||||
colSpan: !index ? columns.length : 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
emptyRowKey = 'key';
|
||||
data = [{
|
||||
[emptyRowKey]: 'empty',
|
||||
}];
|
||||
}
|
||||
|
||||
let table = (
|
||||
<div>
|
||||
<RcTable {...restProps}
|
||||
data={data}
|
||||
columns={columns}
|
||||
className={classString}
|
||||
expandIconColumnIndex={(columns[0] && columns[0].key === 'selection-column') ? 1 : 0}
|
||||
expandIconAsCell={expandIconAsCell}
|
||||
rowKey={emptyRowKey || rowKey}
|
||||
/>
|
||||
{emptyText}
|
||||
</div>
|
||||
);
|
||||
// if there is no pagination or no data,
|
||||
// the height of spin should decrease by half of pagination
|
||||
@ -797,7 +807,7 @@ export default class Table extends React.Component {
|
||||
const spinClassName = this.props.loading ? `${paginationPatchClass} ant-table-spin-holder` : '';
|
||||
table = <Spin className={spinClassName} spinning={this.props.loading}>{table}</Spin>;
|
||||
return (
|
||||
<div className={`${emptyClass} ${className} clearfix`} style={style}>
|
||||
<div className={`${className} clearfix`} style={style}>
|
||||
{table}
|
||||
{this.renderPagination()}
|
||||
</div>
|
||||
|
@ -262,26 +262,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
&-empty {
|
||||
position: relative;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
&-empty &-body {
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
&-placeholder {
|
||||
height: 100px;
|
||||
line-height: 100px;
|
||||
height: 65px;
|
||||
line-height: 65px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
border-bottom: 1px solid @border-color-split;
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
.anticon {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user