Browse Source

fix: table error when use template #1914

pull/1918/head
tanjinzhou 5 years ago
parent
commit
749d74e21f
  1. 6
      components/table/Table.jsx
  2. 7
      components/vc-table/index.js
  3. 6
      components/vc-table/src/TableHeaderRow.jsx

6
components/table/Table.jsx

@ -490,13 +490,15 @@ export default {
return getPopupContainer; return getPopupContainer;
} }
// Use undefined to let rc component use default logic. // Use undefined to let rc component use default logic.
return scroll && table ? () => table.tableNode : undefined; return scroll && table ? () => table.getTableNode() : undefined;
}, },
scrollToFirstRow() { scrollToFirstRow() {
const { scroll } = this.$props; const { scroll } = this.$props;
if (scroll && scroll.scrollToFirstRowOnChange !== false) { if (scroll && scroll.scrollToFirstRowOnChange !== false) {
scrollTo(0, { scrollTo(0, {
getContainer: () => this.$refs.vcTable.bodyTable, getContainer: () => {
return this.$refs.vcTable.getBodyTable();
},
}); });
} }
}, },

7
components/vc-table/index.js

@ -20,6 +20,12 @@ const Table = {
ColumnGroup, ColumnGroup,
props: T.props, props: T.props,
methods: { methods: {
getTableNode() {
return this.$refs.table.tableNode;
},
getBodyTable() {
return this.$refs.table.ref_bodyTable;
},
normalize(elements = []) { normalize(elements = []) {
const columns = []; const columns = [];
elements.forEach(element => { elements.forEach(element => {
@ -63,6 +69,7 @@ const Table = {
columns, columns,
}, },
on: getListeners(this), on: getListeners(this),
ref: 'table',
}; };
return <T {...tProps} />; return <T {...tProps} />;
}, },

6
components/vc-table/src/TableHeaderRow.jsx

@ -51,8 +51,10 @@ const TableHeaderRow = {
} }
headerCellProps.class = classNames( headerCellProps.class = classNames(
customProps.class || customProps.className, customProps.class,
column.class || column.className, customProps.className,
column.class,
column.className,
{ {
[`${prefixCls}-align-${column.align}`]: !!column.align, [`${prefixCls}-align-${column.align}`]: !!column.align,
[`${prefixCls}-row-cell-ellipsis`]: !!column.ellipsis, [`${prefixCls}-row-cell-ellipsis`]: !!column.ellipsis,

Loading…
Cancel
Save