Skip to content

Commit

Permalink
* dtable: fix style not work.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Aug 27, 2024
1 parent d6e1d66 commit d09a36b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/dtable/src/components/dtable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,8 @@ export class DTable extends Component<DTableOptions, DTableState> {

render() {
let layout = this.#getLayout();
const {className, rowHover, colHover, cellHover, bordered, striped, scrollbarHover, beforeRender, emptyTip, style = {}} = this.options;
const {className, rowHover, colHover, cellHover, bordered, striped, scrollbarHover, beforeRender, emptyTip, style} = this.options;
const finalStyle = {...style};
const classNames: ClassNameLike = ['dtable', className, {
'dtable-hover-row': rowHover,
'dtable-hover-col': colHover,
Expand Down Expand Up @@ -1013,10 +1014,10 @@ export class DTable extends Component<DTableOptions, DTableState> {
}
});

style.width = layout.width;
style.height = layout.height;
style['--dtable-row-height'] = `${layout.rowHeight}px`;
style['--dtable-header-height'] = `${layout.headerHeight}px`;
finalStyle.width = layout.width;
finalStyle.height = layout.height;
finalStyle['--dtable-row-height'] = `${layout.rowHeight}px`;
finalStyle['--dtable-header-height'] = `${layout.headerHeight}px`;
classNames.push(
layout.className,
isEmpty ? 'dtable-is-empty' : '',
Expand All @@ -1033,7 +1034,7 @@ export class DTable extends Component<DTableOptions, DTableState> {
children.push(...layout.children);
}
if (isEmpty && emptyTip) {
delete style.height;
delete finalStyle.height;
children.push(
<div key="empty-tip" className="dtable-empty-tip">
<CustomContent content={emptyTip} generatorThis={this} generatorArgs={[layout]} />
Expand All @@ -1056,7 +1057,7 @@ export class DTable extends Component<DTableOptions, DTableState> {
return;
}
if (result.style) {
Object.assign(style, result.style);
Object.assign(finalStyle, result.style);
}
if (result.className) {
classNames.push(result.className);
Expand All @@ -1071,7 +1072,7 @@ export class DTable extends Component<DTableOptions, DTableState> {
<div
id={this._id}
className={classes(classNames)}
style={style}
style={finalStyle}
ref={this.ref}
tabIndex={-1}
>
Expand Down

0 comments on commit d09a36b

Please sign in to comment.