DEV Community

Discussion on: An easy way to create a customize dynamic table in react js

Collapse
datmt profile image
Mạnh Đạt

Thanks for the tutorial. I'm a react beginner.

My question is, what if the number of column is unknown too?

Thanks again

Collapse
abdulbasit313 profile image
Abdul Basit Author • Edited on

Here you go... you just need to change renderTableData function with below code. Let me know if it helps...

   renderTableData() {
      return this.state.students.map((student, index) => {
         let col = Object.keys(student)
         return (
            <tr key={student.id}>
               {col.map((val, index) => {
                  return <td key={index}>{student[col[index]]}</td>
               })}
            </tr>
         )
      })
   }
Collapse
hirupiyumika profile image
hirupiyumika

Thank you very much...!! It is very helpful.

Collapse
ronaldoperes profile image
Ronaldo Peres

Thank you,

How can I hide the first column?

Collapse
datmt profile image
Mạnh Đạt

Thank you!