constantin-p / cp-react-tree-table

A fast, efficient tree table component for ReactJS.
https://constantin.software/cp-react-tree-table
MIT License
95 stars 27 forks source link

Going from TreeState to initial data format #31

Open maewang00 opened 4 years ago

maewang00 commented 4 years ago

After the user finishes their edits on some rows in the table (using ), I was wondering if it is possible to convert the new modified TreeState into the same format as the data used to create the TreeState. How would I do such a thing?

Example: const MOCK_DATA = [ { data: { name: 'Company A', expenses: '105,000', employees: '22', contact: 'Makenzie Higgs' }, children: [ { data: { name: 'Department 1', expenses: '75,000', employees: '18', contact: 'Florence Carter' } } ] } ];

... treeValue: TreeState.create(MOCK_DATA) ...

and then after the edits/changes, we can turn treeValue into the below:

const NEW_MOCK_DATA = [ { data: { name: 'Company A', expenses: '105,000', employees: '22', contact: 'John Doe' }, children: [ { data: { name: 'Department 1', expenses: '75,000', employees: '18', contact: 'John Doe' } } ] } ];