Skip to content

Commit

Permalink
Add Table tableLayout prop
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Jun 25, 2019
1 parent a30dd26 commit 4fe4706
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
7 changes: 4 additions & 3 deletions components/table/Table.tsx
Expand Up @@ -98,6 +98,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
showHeader: true,
sortDirections: ['ascend', 'descend'],
childrenColumnName: 'children',
tableLayout: 'auto',
};

CheckboxPropsCache: {
Expand Down Expand Up @@ -1152,7 +1153,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
dropdownPrefixCls: string,
contextLocale: TableLocale,
) => {
const { style, className, showHeader, locale, ...restProps } = this.props;
const { style, className, showHeader, locale, tableLayout, ...restProps } = this.props;
const data = this.getCurrentPageData();
const expandIconAsCell = this.props.expandedRowRender && this.props.expandIconAsCell !== false;

Expand All @@ -1161,11 +1162,11 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
mergedLocale.emptyText = renderEmpty('Table');
}

const classString = classNames({
[`${prefixCls}-${this.props.size}`]: true,
const classString = classNames(`${prefixCls}-${this.props.size}`, {
[`${prefixCls}-bordered`]: this.props.bordered,
[`${prefixCls}-empty`]: !data.length,
[`${prefixCls}-without-column-header`]: !showHeader,
[`${prefixCls}-layout-${tableLayout}`]: tableLayout === 'fixed',
});

let columns = this.renderRowSelection(prefixCls, mergedLocale);
Expand Down
3 changes: 2 additions & 1 deletion components/table/interface.tsx
Expand Up @@ -177,6 +177,7 @@ export interface TableProps<T> {
bodyStyle?: React.CSSProperties;
className?: string;
style?: React.CSSProperties;
tableLayout?: React.CSSProperties['tableLayout'];
children?: React.ReactNode;
sortDirections?: SortOrder[];
}
Expand Down Expand Up @@ -267,5 +268,5 @@ export type PrepareParamsArgumentsReturn<T> = [
Object,
{
currentDataSource: T[];
}
},
];
4 changes: 4 additions & 0 deletions components/table/style/index.less
Expand Up @@ -32,6 +32,10 @@
border-collapse: collapse;
}

table&-layout-fixed {
table-layout: fixed;
}

&-thead > tr > th {
color: @table-header-color;
font-weight: 500;
Expand Down

0 comments on commit 4fe4706

Please sign in to comment.