Skip to main content

Group

Basic

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 import numeral from 'numeral'; import React from 'react'; import VirtualTable from '../../../../../src/components/VirtualTable'; import { TYPE_CELL } from '../../../../../src/components/VirtualTable/constants/typeCell'; import { ROW_TYPE } from '../../../../../src/components/VirtualTable/utils'; const VirtualTableGroupBasic = () => { const formatAmount = (num, format = '0,0.00') => `${numeral(+(+(num || 0)).toFixed(2)).format(format)} €` .replace(',', ' ') .replace('.', ','); const data = [ { id: 1, amount: 530000, title: 'Total brut bulletins de paies', groupId: 1 }, { id: 3, amount: 0, title: 'Ecart Bulletins de paies - Brut salariés', groupId: 1 }, { id: 4, amount: 150000, title: 'Total brut bulletins de paies', groupId: 2 }, { id: 5, amount: 145000, title: 'Total des comptes 641', groupId: 2 }, { id: 6, amount: 5000, title: 'Ecart Bulletins de paies - Total des comptes 641', groupId: 2 }, { id: 7, amount: 27000, title: 'Total des Cotisations patronales', groupId: 3 }, { id: 8, amount: 27000, title: 'Total des comptes 645', groupId: 3 }, { id: 9, amount: 0, title: 'Ecart Cotisations patronales - Compta', groupId: 3 }, { id: 10, amount: 800000, title: 'Total des comptes 43', groupId: 4 }, { id: 11, amount: 799000, title: 'Total des comptes 641', groupId: 4 }, { id: 2, amount: 530000, title: 'Total brut de tous les salariés', groupId: 1 }, { id: 12, amount: 1000, title: 'Ecart Total brut DSN - Compta', groupId: 4 } ]; const config = { exportFormat: ['csv', 'xls', 'pdf', 'print'], groupKey: 'groupId', modeGroup: true, groupSelection: true, // defaultOrderDirection: 'desc', // sortedGroup: true, columns: [ { header: 'Exercice N', key: 'title', size: 1, style: () => { console.log('title'); } }, { header: 'Amount', width: 150, key: 'amount', typeCell: TYPE_CELL.AMOUNT, alignText: 'right', formatAmount } ] }; return ( <VirtualTable data={data} maxHeight="600px" config={config} tableKeyName="doc-group-Basic" /> ); }; export default VirtualTableGroupBasic;
<VirtualTable
config={{
modeGroup: true,
groupKey: 'groupId',
groupSelection: true,
...
}}

Accordion

The most common use of the group option is in read mode.

Exercice N
Amount
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 import numeral from 'numeral'; import React from 'react'; import VirtualTable from '../../../../../src/components/VirtualTable'; import { TYPE_CELL } from '../../../../../src/components/VirtualTable/constants/typeCell'; import { ROW_TYPE } from '../../../../../src/components/VirtualTable/utils'; import { useDataManager } from '../../../../../src/components/VirtualTable/hooks'; const VirtualTableGroupBasic = () => { const formatAmount = (num, format = '0,0.00') => `${numeral(+(+(num || 0)).toFixed(2)).format(format)} €` .replace(',', ' ') .replace('.', ','); const defaultData = [ { id: 1, name: 'Rapprochement Bulletins de paies issus de la paie - Brut salariés issus de la paie', rowType: ROW_TYPE.GROUP_BUTTON, modeAdd: true, addGroupRowLabel: '+ Ajouter paie', data: [ { id: 101, amount: 530000, title: 'Total brut bulletins de paies', groupId: 1 }, { id: 102, amount: 530000, title: 'Total brut de tous les salariés', groupId: 1 }, { id: 103, amount: 0, title: 'Ecart Bulletins de paies - Brut salariés', groupId: 1, style: { background: '#cef6f6' } } ] }, { id: 2, name: 'Rapprochement Bulletins de paies issus de la paie - Compta', rowType: ROW_TYPE.GROUP_BUTTON, data: [ { id: 4, amount: 150000, title: 'Total brut bulletins de paies', groupId: 2 }, { id: 5, amount: 145000, title: 'Total des comptes 641', groupId: 2 }, { id: 6, amount: 5000, title: 'Ecart Bulletins de paies - Total des comptes 641', groupId: 2, style: { background: '#ffd8df' } } ] }, { id: 3, name: 'Rapprochement Cotisations patronales issus de la paie - Compta', rowType: ROW_TYPE.GROUP_BUTTON, modeAdd: true, data: [ { id: 7, amount: 27000, title: 'Total des Cotisations patronales', groupId: 3 }, { id: 8, amount: 27000, title: 'Total des comptes 645', groupId: 3 }, { id: 9, amount: 0, title: 'Ecart Cotisations patronales - Compta', groupId: 3, style: { background: '#cef6f6' } } ] }, { id: 4, name: 'Rapprochement DSN - Compta', rowType: ROW_TYPE.GROUP_BUTTON, data: [ { id: 10, amount: 800000, title: 'Total des comptes 43', groupId: 4 }, { id: 11, amount: 799000, title: 'Total des comptes 641', groupId: 4 }, { id: 12, amount: 1000, title: 'Ecart Total brut DSN - Compta', groupId: 4, style: { background: '#ffd8df' } } ] } ]; function handleValidateAdd(rows, index) { onAdd(rows, index); } async function handleRowsToDelete(rows) { onDelete(rows) } function handleValidateEdit(rows, index) { onEdit(rows, index); } const config = { defaultCollapsedGroups: [1,2], exportFormat: ['csv', 'xls', 'pdf', 'print'], modeAdd: true, modeDelete: true, modeEdit: true, modeGroup: true, selectableRowKey: 'id', groupKey: 'groupId', collapsedGroup: true, columns: [ { header: 'Exercice N', key: 'title', size: 1, sortable: false, style: () => { console.log('title'); } }, { header: 'Amount', width: 150, key: 'amount', typeCell: TYPE_CELL.AMOUNT, alignText: 'right', sortable: false, formatAmount } ] }; const { data, onAdd, onEdit, onDelete } = useDataManager(defaultData, config.selectableRowKey, config.modeGroup, config.groupKey); return ( <VirtualTable data={data} maxHeight="600px" config={config} tableKeyName="doc-group-Accordion" handleRowsToDelete={handleRowsToDelete} handleValidateAdd={handleValidateAdd} handleValidateEdit={handleValidateEdit} /> ); }; export default VirtualTableGroupBasic;
<VirtualTable
config={{
modeGroup: true,
collapsedGroup: true,
groupKey: 'groupId',
defaultCollapsedGroups: [1,2],
...
}}