mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
docs: Reset filters and sorters - English Translation (#3259)
This commit is contained in:
parent
94f2d08978
commit
5d914d6ba3
@ -30,24 +30,24 @@ import { Table } from 'antd';
|
|||||||
|
|
||||||
const data = [{
|
const data = [{
|
||||||
key: '1',
|
key: '1',
|
||||||
name: '胡斌',
|
name: 'John Brown',
|
||||||
age: 32,
|
age: 32,
|
||||||
address: '南湖区湖底公园1号',
|
address: 'New York No. 1 Lake Park',
|
||||||
}, {
|
}, {
|
||||||
key: '2',
|
key: '2',
|
||||||
name: '胡彦祖',
|
name: 'Jim Green',
|
||||||
age: 42,
|
age: 42,
|
||||||
address: '西湖区湖底公园12号',
|
address: 'London No. 1 Lake Park',
|
||||||
}, {
|
}, {
|
||||||
key: '3',
|
key: '3',
|
||||||
name: '李大嘴',
|
name: 'Joe Black',
|
||||||
age: 32,
|
age: 32,
|
||||||
address: '南湖区湖底公园123号',
|
address: 'Sidney No. 1 Lake Park',
|
||||||
}, {
|
}, {
|
||||||
key: '4',
|
key: '4',
|
||||||
name: '李秀莲大嘴哥',
|
name: 'Jim Red',
|
||||||
age: 32,
|
age: 32,
|
||||||
address: '西湖区湖底公园123号',
|
address: 'London No. 2 Lake Park',
|
||||||
}];
|
}];
|
||||||
|
|
||||||
const App = React.createClass({
|
const App = React.createClass({
|
||||||
@ -58,7 +58,7 @@ const App = React.createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
handleChange(pagination, filters, sorter) {
|
handleChange(pagination, filters, sorter) {
|
||||||
console.log('各类参数是', pagination, filters, sorter);
|
console.log('Various parameters', pagination, filters, sorter);
|
||||||
this.setState({
|
this.setState({
|
||||||
filteredInfo: filters,
|
filteredInfo: filters,
|
||||||
sortedInfo: sorter,
|
sortedInfo: sorter,
|
||||||
@ -89,30 +89,30 @@ const App = React.createClass({
|
|||||||
sortedInfo = sortedInfo || {};
|
sortedInfo = sortedInfo || {};
|
||||||
filteredInfo = filteredInfo || {};
|
filteredInfo = filteredInfo || {};
|
||||||
const columns = [{
|
const columns = [{
|
||||||
title: '姓名',
|
title: 'Name',
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
key: 'name',
|
key: 'name',
|
||||||
filters: [
|
filters: [
|
||||||
{ text: '姓李的', value: '李' },
|
{ text: 'Joe', value: 'Joe' },
|
||||||
{ text: '姓胡的', value: '胡' },
|
{ text: 'Jim', value: 'Jim' },
|
||||||
],
|
],
|
||||||
filteredValue: filteredInfo.name,
|
filteredValue: filteredInfo.name,
|
||||||
onFilter: (value, record) => record.name.includes(value),
|
onFilter: (value, record) => record.name.includes(value),
|
||||||
sorter: (a, b) => a.name.length - b.name.length,
|
sorter: (a, b) => a.name.length - b.name.length,
|
||||||
sortOrder: sortedInfo.columnKey === 'name' && sortedInfo.order,
|
sortOrder: sortedInfo.columnKey === 'name' && sortedInfo.order,
|
||||||
}, {
|
}, {
|
||||||
title: '年龄',
|
title: 'Age',
|
||||||
dataIndex: 'age',
|
dataIndex: 'age',
|
||||||
key: 'age',
|
key: 'age',
|
||||||
sorter: (a, b) => a.age - b.age,
|
sorter: (a, b) => a.age - b.age,
|
||||||
sortOrder: sortedInfo.columnKey === 'age' && sortedInfo.order,
|
sortOrder: sortedInfo.columnKey === 'age' && sortedInfo.order,
|
||||||
}, {
|
}, {
|
||||||
title: '地址',
|
title: 'Address',
|
||||||
dataIndex: 'address',
|
dataIndex: 'address',
|
||||||
key: 'address',
|
key: 'address',
|
||||||
filters: [
|
filters: [
|
||||||
{ text: '南湖', value: '南湖' },
|
{ text: 'London', value: 'London' },
|
||||||
{ text: '西湖', value: '西湖' },
|
{ text: 'New York', value: 'New York' },
|
||||||
],
|
],
|
||||||
filteredValue: filteredInfo.address,
|
filteredValue: filteredInfo.address,
|
||||||
onFilter: (value, record) => record.address.includes(value),
|
onFilter: (value, record) => record.address.includes(value),
|
||||||
@ -122,9 +122,9 @@ const App = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="table-operations">
|
<div className="table-operations">
|
||||||
<a href="#" onClick={this.setAgeSort}>年龄降序排序</a>
|
<a href="#" onClick={this.setAgeSort}>Age descending order</a>
|
||||||
<a href="#" onClick={this.clearFilters}>清除筛选</a>
|
<a href="#" onClick={this.clearFilters}>Clear filters</a>
|
||||||
<a href="#" onClick={this.clearAll}>清除筛选和排序</a>
|
<a href="#" onClick={this.clearAll}>Clear filters and sorting</a>
|
||||||
</div>
|
</div>
|
||||||
<Table columns={columns} dataSource={data} onChange={this.handleChange} />
|
<Table columns={columns} dataSource={data} onChange={this.handleChange} />
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user