0

I am trying to build a table of permissions with react-table.

After working on my data, I have this type of arrray (this is purely an exemple and for each Administrator/Editor/Reader I have other data) :

[
  { Description: 'Create', Administrator: {id: 99, value: 1}, Editor: {id: 98, value: 1}, Reader: {id: 99, value: 0} },
  { Description: 'Delete', Administrator: {id: 99, value: 1}, Editor: {id: 98, value: 0}, Reader: {id: 99, value: 0} },
  { Description: 'Read', Administrator: {id: 99, value: 1}, Editor: {id: 98, value: 1}, Reader: {id: 99, value: 1} },
]

I would like my Column to be Description/Administrator/Editor/Reader.

And for each row (that will correspond to a specific description), I would like to set for exemple a button/checkbox for the column Administrator/Editor/Reader set to their value (1/0) and if the person click/uncheck the button/checkbox in the cell Administrator for the Description 'Read' then I will access the id and change its value in my database.

I uploaded a photo of how I see it.

enter image description here

Is this possible with react table because I can't seem to find any information on how to "assign" multiple data to a cell or should I develop this with another method.

Thank you in advance for any help.

1 Answers1

0

Yes. It is possible to add checkboxes in table cells because react-table is very flexible. But it has has quite overwhelming API (because of its flexibly) though there are a lot of examples. I modified basic example from the link above. Also take a look on this SO answer. Do not give up. React-table gave me a lot struggles too.

Alan Svits
  • 122
  • 1
  • 10
  • Thank your for your answer. Your modified exemple helped me a lot to understand cell in react-table and build my specific table. Now I only have to work on the front end but the logical part is done thanks to you. Have a nice day. – Antoine BATTAGLIOTTI Apr 13 '21 at 16:44