Skip to content

column support align attr #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,11 @@ export default class Table extends React.Component {
rows.push([]);
}
}
const styleProp = column.align ? { textAlign: column.align } : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null => undefined

ci 挂了。

const cell = {
key: column.key,
className: column.className || '',
style: styleProp,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

略好奇,column 这里就不能直接设置 style 属性么? @afc163 @yesmeck

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api好像没有提供,不过我觉得如果开放这个api,直接在配置里面这样写:

column: [{
    styleProp: {textAlign: "center"}
}]

也是可以的,但感觉有些麻烦。。

不过开放这个API之后,我上面的写法确实会有问题,所以要么是通过叠加class,即内部规定三个class,让其定位位置吧?

children: column.title,
};
if (column.children) {
Expand Down
5 changes: 4 additions & 1 deletion src/TableCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export default class TableCell extends React.Component {
render() {
const { record, indentSize, prefixCls, indent,
index, expandIcon, column } = this.props;
const { dataIndex, render, className = '' } = column;
const { dataIndex, render, className = '', align } = column;

const styleProp = align ? { textAlign: align } : null;

// We should return undefined if no dataIndex is specified, but in order to
// be compatible with object-path's behavior, we return the record object instead.
Expand Down Expand Up @@ -72,6 +74,7 @@ export default class TableCell extends React.Component {
return (
<td
className={className}
style={styleProp}
{...tdProps}
onClick={this.handleClick}
>
Expand Down