Guest User

Untitled

a guest
Oct 3rd, 2023
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. import React from 'react';
  2. import { Table, Select } from 'antd';
  3. import type { ColumnsType } from 'antd/es/table';
  4.  
  5. interface DataType {
  6. key: React.Key;
  7. name: string;
  8. age: number;
  9. address: string;
  10. }
  11.  
  12. const columns: ColumnsType<DataType> = [
  13. {
  14. title: 'Full Name',
  15. width: 100,
  16. dataIndex: 'name',
  17. key: 'name',
  18. fixed: 'left',
  19. },
  20. {
  21. title: 'Age',
  22. width: 100,
  23. dataIndex: 'age',
  24. key: 'age',
  25. fixed: 'left',
  26. },
  27. {
  28. title: 'Column 1',
  29. dataIndex: 'address',
  30. key: '1',
  31. width: 150,
  32. },
  33. {
  34. title: 'Column 2',
  35. dataIndex: 'address',
  36. key: '2',
  37. width: 150,
  38. },
  39. {
  40. title: 'Column 3',
  41. dataIndex: 'address',
  42. key: '3',
  43. width: 150,
  44. },
  45. {
  46. title: 'Column 4',
  47. dataIndex: 'address',
  48. key: '4',
  49. width: 150,
  50. },
  51. {
  52. title: 'Column 5',
  53. dataIndex: 'address',
  54. key: '5',
  55. width: 150,
  56. },
  57. {
  58. title: 'Column 6',
  59. dataIndex: 'address',
  60. key: '6',
  61. width: 150,
  62. },
  63. {
  64. title: 'Column 7',
  65. dataIndex: 'address',
  66. key: '7',
  67. width: 150,
  68. },
  69. { title: 'Column 8', dataIndex: 'address', key: '8' },
  70. {
  71. title: 'Action',
  72. key: 'operation',
  73. fixed: 'right',
  74. width: 100,
  75. render: async function(text, record, index) {
  76. return (
  77. <Select
  78. showSearch
  79. placeholder="Select a person"
  80. optionFilterProp="children"
  81. onChange={onChange}
  82. onSearch={onSearch}
  83. filterOption={filterOption}
  84. options={[
  85. {
  86. value: 'jack',
  87. label: 'Jack',
  88. },
  89. {
  90. value: 'lucy',
  91. label: 'Lucy',
  92. },
  93. {
  94. value: 'tom',
  95. label: 'Tom',
  96. },
  97. ]}
  98. />
  99. )
  100. }
  101. },
  102. ];
  103.  
  104. const data: DataType[] = [];
  105. for (let i = 0; i < 100; i++) {
  106. data.push({
  107. key: i,
  108. name: `Edward ${i}`,
  109. age: 32,
  110. address: `London Park no. ${i}`,
  111. });
  112. }
  113.  
  114. function onChange() {
  115. console.log('TODO')
  116. }
  117. function onSearch() {
  118. console.log('TODO')
  119. }
  120. function filterOption() {
  121. console.log('TODO')
  122. return false
  123. }
  124.  
  125. const App: React.FC = () => (
  126. <Table columns={columns} dataSource={data} scroll={{ x: 1500, y: 300 }} />
  127. );
  128.  
  129. export default App;
Advertisement
Add Comment
Please, Sign In to add comment