mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
🎬 Add tableLyout and ellipsis in Table demo
This commit is contained in:
parent
033f812311
commit
251ae17376
File diff suppressed because it is too large
Load Diff
@ -16,21 +16,17 @@ Select different settings to see the result.
|
||||
```jsx
|
||||
import { Table, Icon, Switch, Radio, Form, Divider } from 'antd';
|
||||
|
||||
const FormItem = Form.Item;
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: 'Name',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 150,
|
||||
render: text => <a>{text}</a>,
|
||||
},
|
||||
{
|
||||
title: 'Age',
|
||||
dataIndex: 'age',
|
||||
key: 'age',
|
||||
width: 70,
|
||||
},
|
||||
{
|
||||
title: 'Address',
|
||||
@ -40,7 +36,6 @@ const columns = [
|
||||
{
|
||||
title: 'Action',
|
||||
key: 'action',
|
||||
width: 360,
|
||||
render: (text, record) => (
|
||||
<span>
|
||||
<a>Action 一 {record.name}</a>
|
||||
@ -86,6 +81,7 @@ class Demo extends React.Component {
|
||||
rowSelection: {},
|
||||
scroll: undefined,
|
||||
hasData: true,
|
||||
tableLayout: undefined,
|
||||
};
|
||||
|
||||
handleToggle = prop => enable => {
|
||||
@ -96,10 +92,18 @@ class Demo extends React.Component {
|
||||
this.setState({ size: e.target.value });
|
||||
};
|
||||
|
||||
handleTableLayoutChange = e => {
|
||||
this.setState({ tableLayout: e.target.value });
|
||||
};
|
||||
|
||||
handleExpandChange = enable => {
|
||||
this.setState({ expandedRowRender: enable ? expandedRowRender : undefined });
|
||||
};
|
||||
|
||||
handleEllipsisChange = enable => {
|
||||
this.setState({ ellipsis: enable });
|
||||
};
|
||||
|
||||
handleTitleChange = enable => {
|
||||
this.setState({ title: enable ? title : undefined });
|
||||
};
|
||||
@ -135,56 +139,71 @@ class Demo extends React.Component {
|
||||
const { state } = this;
|
||||
return (
|
||||
<div>
|
||||
<div className="components-table-demo-control-bar">
|
||||
<Form layout="inline">
|
||||
<FormItem label="Bordered">
|
||||
<Switch checked={state.bordered} onChange={this.handleToggle('bordered')} />
|
||||
</FormItem>
|
||||
<FormItem label="loading">
|
||||
<Switch checked={state.loading} onChange={this.handleToggle('loading')} />
|
||||
</FormItem>
|
||||
<FormItem label="Title">
|
||||
<Switch checked={!!state.title} onChange={this.handleTitleChange} />
|
||||
</FormItem>
|
||||
<FormItem label="Column Header">
|
||||
<Switch checked={!!state.showHeader} onChange={this.handleHeaderChange} />
|
||||
</FormItem>
|
||||
<FormItem label="Footer">
|
||||
<Switch checked={!!state.footer} onChange={this.handleFooterChange} />
|
||||
</FormItem>
|
||||
<FormItem label="Expandable">
|
||||
<Switch checked={!!state.expandedRowRender} onChange={this.handleExpandChange} />
|
||||
</FormItem>
|
||||
<FormItem label="Checkbox">
|
||||
<Switch checked={!!state.rowSelection} onChange={this.handleRowSelectionChange} />
|
||||
</FormItem>
|
||||
<FormItem label="Fixed Header">
|
||||
<Switch checked={!!state.scroll} onChange={this.handleScollChange} />
|
||||
</FormItem>
|
||||
<FormItem label="Has Data">
|
||||
<Switch checked={!!state.hasData} onChange={this.handleDataChange} />
|
||||
</FormItem>
|
||||
<FormItem label="Size">
|
||||
<Radio.Group size="default" value={state.size} onChange={this.handleSizeChange}>
|
||||
<Radio.Button value="default">Default</Radio.Button>
|
||||
<Radio.Button value="middle">Middle</Radio.Button>
|
||||
<Radio.Button value="small">Small</Radio.Button>
|
||||
</Radio.Group>
|
||||
</FormItem>
|
||||
<FormItem label="Pagination">
|
||||
<Radio.Group
|
||||
value={state.pagination ? state.pagination.position : 'none'}
|
||||
onChange={this.handlePaginationChange}
|
||||
>
|
||||
<Radio.Button value="top">Top</Radio.Button>
|
||||
<Radio.Button value="bottom">Bottom</Radio.Button>
|
||||
<Radio.Button value="both">Both</Radio.Button>
|
||||
<Radio.Button value="none">None</Radio.Button>
|
||||
</Radio.Group>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</div>
|
||||
<Table {...this.state} columns={columns} dataSource={state.hasData ? data : null} />
|
||||
<Form
|
||||
layout="inline"
|
||||
className="components-table-demo-control-bar"
|
||||
style={{ marginBottom: 16 }}
|
||||
>
|
||||
<Form.Item label="Bordered">
|
||||
<Switch checked={state.bordered} onChange={this.handleToggle('bordered')} />
|
||||
</Form.Item>
|
||||
<Form.Item label="loading">
|
||||
<Switch checked={state.loading} onChange={this.handleToggle('loading')} />
|
||||
</Form.Item>
|
||||
<Form.Item label="Title">
|
||||
<Switch checked={!!state.title} onChange={this.handleTitleChange} />
|
||||
</Form.Item>
|
||||
<Form.Item label="Column Header">
|
||||
<Switch checked={!!state.showHeader} onChange={this.handleHeaderChange} />
|
||||
</Form.Item>
|
||||
<Form.Item label="Footer">
|
||||
<Switch checked={!!state.footer} onChange={this.handleFooterChange} />
|
||||
</Form.Item>
|
||||
<Form.Item label="Expandable">
|
||||
<Switch checked={!!state.expandedRowRender} onChange={this.handleExpandChange} />
|
||||
</Form.Item>
|
||||
<Form.Item label="Checkbox">
|
||||
<Switch checked={!!state.rowSelection} onChange={this.handleRowSelectionChange} />
|
||||
</Form.Item>
|
||||
<Form.Item label="Fixed Header">
|
||||
<Switch checked={!!state.scroll} onChange={this.handleScollChange} />
|
||||
</Form.Item>
|
||||
<Form.Item label="Has Data">
|
||||
<Switch checked={!!state.hasData} onChange={this.handleDataChange} />
|
||||
</Form.Item>
|
||||
<Form.Item label="Ellipsis">
|
||||
<Switch checked={!!state.ellipsis} onChange={this.handleEllipsisChange} />
|
||||
</Form.Item>
|
||||
<Form.Item label="Size">
|
||||
<Radio.Group value={state.size} onChange={this.handleSizeChange}>
|
||||
<Radio.Button value="default">Default</Radio.Button>
|
||||
<Radio.Button value="middle">Middle</Radio.Button>
|
||||
<Radio.Button value="small">Small</Radio.Button>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Form.Item label="Table Layout">
|
||||
<Radio.Group value={state.tableLayout} onChange={this.handleTableLayoutChange}>
|
||||
<Radio.Button value={undefined}>Unset</Radio.Button>
|
||||
<Radio.Button value="fixed">Fixed</Radio.Button>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Form.Item label="Pagination">
|
||||
<Radio.Group
|
||||
value={state.pagination ? state.pagination.position : 'none'}
|
||||
onChange={this.handlePaginationChange}
|
||||
>
|
||||
<Radio.Button value="top">Top</Radio.Button>
|
||||
<Radio.Button value="bottom">Bottom</Radio.Button>
|
||||
<Radio.Button value="both">Both</Radio.Button>
|
||||
<Radio.Button value="none">None</Radio.Button>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<Table
|
||||
{...this.state}
|
||||
columns={columns.map(item => ({ ...item, ellipsis: state. ellipsis }))}
|
||||
dataSource={state.hasData ? data : null}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -194,9 +213,6 @@ ReactDOM.render(<Demo />, mountNode);
|
||||
```
|
||||
|
||||
<style>
|
||||
.components-table-demo-control-bar {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.components-table-demo-control-bar .ant-form-item {
|
||||
margin-right: 16px;
|
||||
margin-bottom: 8px;
|
||||
|
@ -617,7 +617,6 @@
|
||||
overflow: auto;
|
||||
overflow-x: hidden;
|
||||
table {
|
||||
width: auto;
|
||||
min-width: 100%;
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/14545
|
||||
|
Loading…
Reference in New Issue
Block a user