Muneeb K
Muneeb K

Reputation: 487

Column not showing data using Gridjs while integrating with React js

currently I am using Gridjs to display my table in my Reactjs application.

enter image description here

This is the code, the Name, and Email is displaying correctly, but the created_at is not, giving me empty. How can I display the data? thank you..

Upvotes: 2

Views: 741

Answers (1)

Afshin Mehrabani
Afshin Mehrabani

Reputation: 34929

You need to define a custom id for your column if you're using a JSON input.

Example:

const grid = new Grid({
  columns: [{
     id: 'name',
     name: 'Name'
  }, {
     id: 'email',
     name: 'Email'
  }, {
     id: 'phoneNumber',
     name: 'Phone Number'
  }],
  data: [
    { name: 'John', email: '[email protected]', phoneNumber: '(353) 01 222 3333' },
    { name: 'Mark', email: '[email protected]', phoneNumber: '(01) 22 888 4444' },
  ]
});

See https://gridjs.io/docs/examples/import-json/

Upvotes: 3

Related Questions