--- order: 100 title: en-US: Dynamic Settings zh-CN: 动态控制表格属性 --- ## zh-CN 选择不同配置组合查看效果。 ## en-US Select different settings to see the result. ```jsx import { Table, Switch, Radio, Form } from 'antd'; import { DownOutlined } from '@ant-design/icons'; const columns = [ { title: 'Name', dataIndex: 'name', }, { title: 'Age', dataIndex: 'age', sorter: (a, b) => a.age - b.age, }, { title: 'Address', dataIndex: 'address', filters: [ { text: 'London', value: 'London', }, { text: 'New York', value: 'New York', }, ], onFilter: (value, record) => record.address.indexOf(value) === 0, }, { title: 'Action', key: 'action', sorter: true, filters: [], onFilter: () => {}, render: () => ( Delete More actions ), }, ]; const data = []; for (let i = 1; i <= 10; i++) { data.push({ key: i, name: 'John Brown', age: `${i}2`, address: `New York No. ${i} Lake Park`, description: `My name is John Brown, I am ${i}2 years old, living in New York No. ${i} Lake Park.`, }); } const expandable = { expandedRowRender: record =>

{record.description}

}; const title = () => 'Here is title'; const showHeader = true; const footer = () => 'Here is footer'; const pagination = { position: 'bottom' }; class Demo extends React.Component { state = { bordered: false, loading: false, pagination, size: 'default', expandable, title: undefined, showHeader, footer, rowSelection: {}, scroll: undefined, hasData: true, tableLayout: undefined, }; handleToggle = prop => enable => { this.setState({ [prop]: enable }); }; handleSizeChange = e => { this.setState({ size: e.target.value }); }; handleTableLayoutChange = e => { this.setState({ tableLayout: e.target.value }); }; handleExpandChange = enable => { this.setState({ expandable: enable ? expandable : undefined }); }; handleEllipsisChange = enable => { this.setState({ ellipsis: enable }); }; handleTitleChange = enable => { this.setState({ title: enable ? title : undefined }); }; handleHeaderChange = enable => { this.setState({ showHeader: enable ? showHeader : false }); }; handleFooterChange = enable => { this.setState({ footer: enable ? footer : undefined }); }; handleRowSelectionChange = enable => { this.setState({ rowSelection: enable ? {} : undefined }); }; handleYScrollChange = enable => { this.setState({ yScroll: enable }); }; handleXScrollChange = e => { this.setState({ xScroll: e.target.value }); }; handleDataChange = hasData => { this.setState({ hasData }); }; handlePaginationChange = e => { const { value } = e.target; this.setState({ pagination: value === 'none' ? false : { position: value }, }); }; render() { const { xScroll, yScroll, ...state } = this.state; const scroll = {}; if (yScroll) { scroll.y = 240; } if (xScroll) { scroll.x = '100vw'; } const tableColumns = columns.map(item => ({ ...item, ellipsis: state.ellipsis })); if (xScroll === 'fixed') { tableColumns[0].fixed = true; tableColumns[tableColumns.length - 1].fixed = 'right'; } return (
Default Middle Small Unset Scroll Fixed Columns Unset Fixed Top Bottom Both None
); } } ReactDOM.render(, mountNode); ```