index.jsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import React from 'react';
  2. import { Table, Tag, Tooltip } from '@douyinfe/semi-ui';
  3. export default class Demo extends React.Component {
  4. constructor(props = {}) {
  5. super(props);
  6. this.columns = [
  7. {
  8. title: 'Name',
  9. dataIndex: 'name',
  10. width: 150,
  11. //fixed: true,
  12. filters: [
  13. {
  14. text: 'Code 45',
  15. value: '45',
  16. },
  17. {
  18. text: 'King 4',
  19. value: 'King 4',
  20. },
  21. ],
  22. onFilter: (value, record) => record.name.includes(value),
  23. },
  24. {
  25. title: 'Age',
  26. dataIndex: 'age',
  27. width: 150,
  28. sorter: (a, b) => (a.age - b.age > 0 ? 1 : -1),
  29. },
  30. {
  31. title: 'Address',
  32. // width: 200,
  33. dataIndex: 'address',
  34. },
  35. {
  36. // fixed: 'right',
  37. width: 250,
  38. render: (text, record) => (
  39. <Tooltip content={record.description}>
  40. <Tag color="green">Show Info</Tag>
  41. </Tooltip>
  42. ),
  43. },
  44. ];
  45. this.data = [];
  46. for (let i = 0; i < 1000; i++) {
  47. let age = (i * 1000) % 149 ;
  48. let name = `Edward King ${i}`;
  49. this.data.push({
  50. key: '' + i,
  51. name,
  52. age,
  53. address: `London, Park Lane no. ${i}`,
  54. description: `My name is ${name}, I am ${age} years old, living in New York No. ${i + 1} Lake Park.`,
  55. });
  56. }
  57. this.scroll = { y: 400 };
  58. this.style = { width: 750, margin: '0 auto' };
  59. }
  60. render() {
  61. return (
  62. <>
  63. <Table
  64. pagination={false}
  65. columns={this.columns}
  66. dataSource={this.data}
  67. scroll={this.scroll}
  68. style={this.style}
  69. virtualized
  70. /><br /><br />
  71. <Table
  72. pagination={false}
  73. columns={this.columns}
  74. dataSource={this.data}
  75. scroll={this.scroll}
  76. style={this.style}
  77. virtualized
  78. bordered
  79. /><br /><br />
  80. </>
  81. );
  82. }
  83. }