Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ddcat1115 authored and afc163 committed Aug 30, 2016
1 parent 61838ca commit bffdf73
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
24 changes: 4 additions & 20 deletions components/table/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -756,15 +756,16 @@ export default class Table extends React.Component {
}

render() {
const { style, className, rowKey, ...restProps } = this.props;
let data = this.getCurrentPageData();
const { style, className, ...restProps } = this.props;
const data = this.getCurrentPageData();
let columns = this.renderRowSelection();
const expandIconAsCell = this.props.expandedRowRender && this.props.expandIconAsCell !== false;
const locale = this.getLocale();

const classString = classNames({
[`ant-table-${this.props.size}`]: true,
'ant-table-bordered': this.props.bordered,
'ant-table-empty': !data.length,
});

columns = this.renderColumnsDropdown(columns);
Expand All @@ -774,31 +775,14 @@ export default class Table extends React.Component {
return newColumn;
});

// Empty Data
let emptyRowKey;
if (!data || data.length === 0) {
columns.forEach((column, index) => {
column.render = () => ({
children: !index ? <div className="ant-table-placeholder">{locale.emptyText}</div> : null,
props: {
colSpan: !index ? columns.length : 0,
},
});
});
emptyRowKey = 'key';
data = [{
[emptyRowKey]: 'empty',
}];
}

let table = (
<RcTable {...restProps}
data={data}
columns={columns}
className={classString}
expandIconColumnIndex={(columns[0] && columns[0].key === 'selection-column') ? 1 : 0}
expandIconAsCell={expandIconAsCell}
rowKey={emptyRowKey || rowKey}
emptyText={() => locale.emptyText}
/>
);
// if there is no pagination or no data,
Expand Down
15 changes: 13 additions & 2 deletions components/table/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
padding: 16px 8px;
background: @table-head-background-color;
position: relative;
z-index: 2;
top: -1px;
border-radius: 0 0 @border-radius-base @border-radius-base;
}
Expand Down Expand Up @@ -245,12 +246,19 @@
.@{table-prefix-cls}-fixed-right {
border-left: 1px solid @border-color-split;
}
.@{table-prefix-cls}-placeholder {
border-bottom: 0;
}
}

.@{table-prefix-cls}-thead > tr > th {
border-bottom: 1px solid @border-color-split;
}

&.@{table-prefix-cls}-empty .@{table-prefix-cls}-thead > tr > th {
border-bottom: 0;
}

.@{table-prefix-cls}-tbody tr:last-child {
> th,
> td {
Expand All @@ -268,9 +276,12 @@
}

&-placeholder {
height: 65px;
line-height: 65px;
padding: 16px 8px;
background: #fff;
border-bottom: 1px solid @border-color-split;;
text-align: center;
position: relative;
z-index: 2;
font-size: 12px;
color: #999;
.anticon {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"rc-slider": "~4.0.0",
"rc-steps": "~2.1.5",
"rc-switch": "~1.4.2",
"rc-table": "~4.4.0",
"rc-table": "~4.6.0",
"rc-tabs": "~5.9.2",
"rc-time-picker": "~1.1.6",
"rc-tooltip": "~3.4.2",
Expand Down

0 comments on commit bffdf73

Please sign in to comment.