ExpandRowByClick.jsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import React from 'react';
  2. import { Table } from '@douyinfe/semi-ui';
  3. function App() {
  4. const columns = [
  5. {
  6. title: 'Name',
  7. dataIndex: 'name',
  8. fixed: 'left',
  9. render: text => <a>{text}</a>,
  10. },
  11. {
  12. title: 'Age',
  13. dataIndex: 'age',
  14. },
  15. {
  16. title: 'Address',
  17. dataIndex: 'address',
  18. },
  19. ];
  20. const data = [
  21. {
  22. key: '1',
  23. name: 'John Brown',
  24. age: 32,
  25. age1: 23,
  26. age2: 11,
  27. address: 'New York No. 1 Lake Park, New York No. 1 Lake Park',
  28. },
  29. {
  30. key: '2',
  31. name: 'Jim Green',
  32. age: 42,
  33. age1: 23,
  34. age2: 11,
  35. address: 'London No. 1 Lake Park',
  36. },
  37. {
  38. key: '3',
  39. name: 'Joe Black',
  40. age: 32,
  41. age1: 23,
  42. age2: 11,
  43. address: 'Sidney No. 1 Lake Park',
  44. },
  45. {
  46. key: '4',
  47. name: 'Disabled User',
  48. age: 99,
  49. age1: 23,
  50. age2: 11,
  51. address: 'Sidney No. 1 Lake Park',
  52. },
  53. ];
  54. return (
  55. <>
  56. <Table
  57. expandRowByClick
  58. onExpand={(...args) => {
  59. console.log('click row', ...args);
  60. }}
  61. onExpandedRowsChange={rows => {
  62. console.log('rows change', rows);
  63. }}
  64. onRow={() => ({
  65. onClick: (...args) => console.log('onRow click', ...args),
  66. })}
  67. expandedRowRender={() => <div>Semi Design</div>}
  68. columns={columns}
  69. dataSource={data}
  70. />
  71. </>
  72. );
  73. }
  74. export default App;