index.jsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import React from 'react';
  2. import { Table, Tag, Tooltip } from '../../../index';
  3. export default class FixedTableApp 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. filterMultiple: false,
  13. filters: [
  14. {
  15. // text: <span style={{ display: 'inline-flex', width: '100%', height: '100%' }}></span>,
  16. text: '',
  17. value: '',
  18. },
  19. {
  20. text: 'Code 45',
  21. value: '45',
  22. },
  23. {
  24. text: 'King 4',
  25. value: 'King 4',
  26. },
  27. ],
  28. onFilter: (value, record) => record.name.includes(value),
  29. },
  30. {
  31. title: 'Age',
  32. dataIndex: 'age',
  33. width: 150,
  34. sorter: (a, b) => (a.age - b.age > 0 ? 1 : -1),
  35. },
  36. {
  37. title: 'Address',
  38. width: 200,
  39. dataIndex: 'address',
  40. },
  41. {
  42. title: 'Description',
  43. // width: 400,
  44. dataIndex: 'description',
  45. },
  46. {
  47. fixed: 'right',
  48. width: 250,
  49. render: (text, record) => (
  50. <Tooltip content={record.description}>
  51. <Tag color="green">Show Info</Tag>
  52. </Tooltip>
  53. ),
  54. },
  55. ];
  56. this.data = [];
  57. this.rowSelection = {
  58. onChange: (selectedRowKeys, selectedRows) => {
  59. // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
  60. },
  61. getCheckboxProps: record => ({
  62. disabled: record.name === 'Disabled User', // Column configuration not to be checked
  63. name: record.name,
  64. }),
  65. };
  66. for (let i = 0; i < 46; i++) {
  67. let age = (i * 1000) % 149 ;
  68. let name = `Edward King ${i}`;
  69. this.data.push({
  70. key: '' + i,
  71. name,
  72. age,
  73. address: `London, Park Lane no. ${i}`,
  74. description: `My name is ${name}, I am ${age} years old, living in New York No. ${i + 1} Lake Park.`,
  75. });
  76. }
  77. this.scroll = { y: 300, x: `160%` };
  78. }
  79. render() {
  80. return (
  81. <Table
  82. resizable
  83. bordered
  84. columns={this.columns}
  85. dataSource={this.data}
  86. expandedRowRender={record => (
  87. <article>
  88. {record.description}
  89. {record.description}
  90. {record.description}
  91. {record.description}
  92. </article>
  93. )}
  94. scroll={this.scroll}
  95. />
  96. );
  97. }
  98. }