Skip to content

Commit 425e03b

Browse files
committed
Merge branch 'master' of github.com:react-component/table
2 parents 892831b + 4be096c commit 425e03b

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

assets/index.less

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@
6666
border-bottom: 1px solid @table-border-color;
6767
text-align: center;
6868
position: relative;
69+
&-fixed-columns {
70+
position: absolute;
71+
bottom: 0;
72+
width: 100%;
73+
background: transparent;
74+
pointer-events: none;
75+
}
6976
}
7077

7178
table {
@@ -82,6 +89,10 @@
8289

8390
td {
8491
border-bottom: 1px solid @table-border-color;
92+
&:empty:after {
93+
content: '.'; // empty cell placeholder
94+
visibility: hidden;
95+
}
8596
}
8697

8798
tr {

src/Table.jsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export default class Table extends React.Component {
294294
);
295295
}
296296

297-
getRowsByData(data, visible, indent, columns, fixed) {
297+
getRowsByData(originalData, visible, indent, columns, fixed) {
298298
const props = this.props;
299299
const {
300300
childrenColumnName,
@@ -315,7 +315,10 @@ export default class Table extends React.Component {
315315

316316
const expandIconAsCell = fixed !== 'right' ? props.expandIconAsCell : false;
317317
const expandIconColumnIndex = fixed !== 'right' ? props.expandIconColumnIndex : -1;
318-
318+
let data = originalData;
319+
if (this.columnManager.isAnyColumnsFixed() && data.length === 0) {
320+
data = [{ key: 'empty-placeholder-data' }];
321+
}
319322
for (let i = 0; i < data.length; i++) {
320323
const record = data[i];
321324
const key = this.getRowKey(record, i);
@@ -571,11 +574,17 @@ export default class Table extends React.Component {
571574

572575
getEmptyText() {
573576
const { emptyText, prefixCls, data } = this.props;
574-
return !data.length ? (
575-
<div className={`${prefixCls}-placeholder`} key="emptyText">
577+
if (data.length) {
578+
return null;
579+
}
580+
const fixed = this.columnManager.isAnyColumnsFixed();
581+
const emptyClassName =
582+
`${prefixCls}-placeholder${fixed ? ` ${prefixCls}-placeholder-fixed-columns` : ''}`;
583+
return (
584+
<div className={emptyClassName} key="emptyText">
576585
{(typeof emptyText === 'function') ? emptyText() : emptyText}
577586
</div>
578-
) : null;
587+
);
579588
}
580589

581590
getHeaderRowStyle(columns, rows) {

0 commit comments

Comments
 (0)