This commit is contained in:
wanghaoo 2018-11-27 14:32:30 +08:00
parent 5698aff389
commit 18e161ddc9
6 changed files with 41 additions and 30 deletions

View File

@ -57,6 +57,7 @@ class Demo22 extends Component {
render() { render() {
return <DragColumnTable columns={columns22} data={data22} bordered return <DragColumnTable columns={columns22} data={data22} bordered
draggable={true} draggable={true}
/>; />;
} }

File diff suppressed because one or more lines are too long

38
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

@ -341,23 +341,33 @@ class Table extends Component {
} }
getHeaderRows(columns, currentRow = 0, rows) { getHeaderRows(columns, currentRow = 0, rows) {
let { contentWidthDiff = 0, lastShowIndex = 0 } = this.state;
let filterCol = []; let filterCol = [];
rows = rows || []; rows = rows || [];
rows[currentRow] = rows[currentRow] || []; rows[currentRow] = rows[currentRow] || [];
columns.forEach(column => { columns.forEach((column,i) => {
if (column.rowSpan && rows.length < column.rowSpan) { if (column.rowSpan && rows.length < column.rowSpan) {
while (rows.length < column.rowSpan) { while (rows.length < column.rowSpan) {
rows.push([]); rows.push([]);
} }
} }
let width = column.width;
if (typeof (width) == 'string' && width.indexOf('%') > -1 && this.contentWidth) {
width = parseInt(this.contentWidth * parseInt(width) / 100);
} else if (width) {
width = parseInt(width);
}
if (lastShowIndex == i && width) {
width = width + contentWidthDiff;
}
const cell = { const cell = {
key: column.key, key: column.key,
className: column.className || '', className: column.className || '',
children: column.title, children: column.title,
drgHover: column.drgHover, drgHover: column.drgHover,
fixed: column.fixed, fixed: column.fixed,
width: column.width, width: width,
dataindex:column.dataIndex dataindex:column.dataIndex
}; };
if (column.onHeadCellClick) { if (column.onHeadCellClick) {

View File

@ -400,6 +400,7 @@ class TableHeader extends Component {
} }
}; };
render() { render() {
const {dragAbleOrBord,dragAbleOrBordStart} = this.state; const {dragAbleOrBord,dragAbleOrBordStart} = this.state;
const { const {
@ -438,19 +439,8 @@ class TableHeader extends Component {
if (!fixed && da.fixed) { if (!fixed && da.fixed) {
fixedStyle = `${clsPrefix}-row-fixed-columns-in-body`; fixedStyle = `${clsPrefix}-row-fixed-columns-in-body`;
} }
if (
typeof da.width == "string" &&
da.width.indexOf("%") > -1 &&
this.props.contentWidth
) {
da.width = parseInt(
(this.props.contentWidth * parseInt(da.width)) / 100
);
} else if (da.width) {
da.width = parseInt(da.width);
}
if (lastShowIndex == i) { if (lastShowIndex == i) {
da.width = parseInt(da.width) + contentWidthDiff;
canDotDrag = "th-can-not-drag"; canDotDrag = "th-can-not-drag";
} }
if (filterable && index == rows.length - 1) { if (filterable && index == rows.length - 1) {