update table demo code style

This commit is contained in:
afc163 2016-03-28 16:00:58 +08:00
parent 127f893619
commit bc2bafff54

View File

@ -29,61 +29,51 @@ const columns = [{
}, { }, {
text: '姓王的', text: '姓王的',
value: '王', value: '王',
}] }],
}], }],
// 指定确定筛选的条件函数 // 指定确定筛选的条件函数
// 这里是名字中第一个字是 value // 这里是名字中第一个字是 value
onFilter(value, record) { onFilter: (value, record) => record.name.indexOf(value) === 0,
return record.name.indexOf(value) === 0; sorter: (a, b) => a.name.length - b.name.length,
},
sorter(a, b) {
return a.name.length - b.name.length;
}
}, { }, {
title: '年龄', title: '年龄',
dataIndex: 'age', dataIndex: 'age',
sorter(a, b) { sorter: (a, b) => a.age - b.age,
return a.age - b.age;
}
}, { }, {
title: '地址', title: '地址',
dataIndex: 'address', dataIndex: 'address',
filters: [{ filters: [{
text: '南湖', text: '南湖',
value: '南湖' value: '南湖',
}, { }, {
text: '西湖', text: '西湖',
value: '西湖' value: '西湖',
}], }],
filterMultiple: false, filterMultiple: false,
onFilter(value, record) { onFilter: (value, record) => record.address.indexOf(value) === 0,
return record.address.indexOf(value) === 0; sorter: (a, b) => a.address.length - b.address.length,
},
sorter(a, b) {
return a.address.length - b.address.length;
}
}]; }];
const data = [{ const data = [{
key: '1', key: '1',
name: '胡斌', name: '胡斌',
age: 32, age: 32,
address: '南湖区湖底公园1号' address: '南湖区湖底公园1号',
}, { }, {
key: '2', key: '2',
name: '胡彦祖', name: '胡彦祖',
age: 42, age: 42,
address: '西湖区湖底公园12号' address: '西湖区湖底公园12号',
}, { }, {
key: '3', key: '3',
name: '李大嘴', name: '李大嘴',
age: 32, age: 32,
address: '南湖区湖底公园123号' address: '南湖区湖底公园123号',
}, { }, {
key: '4', key: '4',
name: '李秀莲大嘴哥', name: '李秀莲大嘴哥',
age: 32, age: 32,
address: '西湖区湖底公园123号' address: '西湖区湖底公园123号',
}]; }];
function onChange(pagination, filters, sorter) { function onChange(pagination, filters, sorter) {
@ -91,6 +81,5 @@ function onChange(pagination, filters, sorter) {
console.log('各类参数是', pagination, filters, sorter); console.log('各类参数是', pagination, filters, sorter);
} }
ReactDOM.render(<Table columns={columns} dataSource={data} onChange={onChange} /> ReactDOM.render(<Table columns={columns} dataSource={data} onChange={onChange} />, mountNode);
, mountNode);
```` ````