Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MUIDataTable 'customBodyRender' error

I am doing a ReactJS Application, working with a rest API, and I want to test the node packages MUI-datatables, to display a list.

But I get the error : 'TypeError: Cannot read property 'customBodyRender' of undefined'

Here is my code :

render() {
   const columns = ["URL", "Modele"];
   const test = [
     ["Joe James", "Test Corp", "Yonkers", "NY"]
   ];
   const options = {
     filterType: 'checkbox',
   };
   return (
      <div>
         <MUIDataTable title={"Offree"} data={test} columns={columns} options={options}/>
   </div>)
   }
}

Thanks for your answer !

like image 318
asa Avatar asked Aug 02 '18 09:08

asa


1 Answers

You'll have to match the amount of items in columns with the amount of items in test. Currently, you have two more items in your data, compared to your columns. For example, the following will fix:

    const columns = ["URL", "Modele", "thirdColumn", "fourthColumn"];

If you don't want to display the third and fourth column, you can set display: false in your column options:

const columns = [
        {
            name: "URL",
            options: {
                display: true
            }
        },
        {
            name: "Modele",
            options: {
                display: true
            }
        },
        {
            name: "thirdColumn",
            options: {
                display: false
            }
        },
        {
            name: "fourthColumn",
            options: {
                display: false
            }
        }

    ]
like image 85
pancakesmaplesyrup Avatar answered Oct 20 '22 06:10

pancakesmaplesyrup