mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-12 04:13:13 +08:00
update table demo code style
This commit is contained in:
parent
127f893619
commit
bc2bafff54
@ -29,61 +29,51 @@ const columns = [{
|
||||
}, {
|
||||
text: '姓王的',
|
||||
value: '王',
|
||||
}]
|
||||
}],
|
||||
}],
|
||||
// 指定确定筛选的条件函数
|
||||
// 这里是名字中第一个字是 value
|
||||
onFilter(value, record) {
|
||||
return record.name.indexOf(value) === 0;
|
||||
},
|
||||
sorter(a, b) {
|
||||
return a.name.length - b.name.length;
|
||||
}
|
||||
onFilter: (value, record) => record.name.indexOf(value) === 0,
|
||||
sorter: (a, b) => a.name.length - b.name.length,
|
||||
}, {
|
||||
title: '年龄',
|
||||
dataIndex: 'age',
|
||||
sorter(a, b) {
|
||||
return a.age - b.age;
|
||||
}
|
||||
sorter: (a, b) => a.age - b.age,
|
||||
}, {
|
||||
title: '地址',
|
||||
dataIndex: 'address',
|
||||
filters: [{
|
||||
text: '南湖',
|
||||
value: '南湖'
|
||||
value: '南湖',
|
||||
}, {
|
||||
text: '西湖',
|
||||
value: '西湖'
|
||||
value: '西湖',
|
||||
}],
|
||||
filterMultiple: false,
|
||||
onFilter(value, record) {
|
||||
return record.address.indexOf(value) === 0;
|
||||
},
|
||||
sorter(a, b) {
|
||||
return a.address.length - b.address.length;
|
||||
}
|
||||
onFilter: (value, record) => record.address.indexOf(value) === 0,
|
||||
sorter: (a, b) => a.address.length - b.address.length,
|
||||
}];
|
||||
|
||||
const data = [{
|
||||
key: '1',
|
||||
name: '胡斌',
|
||||
age: 32,
|
||||
address: '南湖区湖底公园1号'
|
||||
address: '南湖区湖底公园1号',
|
||||
}, {
|
||||
key: '2',
|
||||
name: '胡彦祖',
|
||||
age: 42,
|
||||
address: '西湖区湖底公园12号'
|
||||
address: '西湖区湖底公园12号',
|
||||
}, {
|
||||
key: '3',
|
||||
name: '李大嘴',
|
||||
age: 32,
|
||||
address: '南湖区湖底公园123号'
|
||||
address: '南湖区湖底公园123号',
|
||||
}, {
|
||||
key: '4',
|
||||
name: '李秀莲大嘴哥',
|
||||
age: 32,
|
||||
address: '西湖区湖底公园123号'
|
||||
address: '西湖区湖底公园123号',
|
||||
}];
|
||||
|
||||
function onChange(pagination, filters, sorter) {
|
||||
@ -91,6 +81,5 @@ function onChange(pagination, filters, sorter) {
|
||||
console.log('各类参数是', pagination, filters, sorter);
|
||||
}
|
||||
|
||||
ReactDOM.render(<Table columns={columns} dataSource={data} onChange={onChange} />
|
||||
, mountNode);
|
||||
ReactDOM.render(<Table columns={columns} dataSource={data} onChange={onChange} />, mountNode);
|
||||
````
|
||||
|
Loading…
Reference in New Issue
Block a user