2

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..

1 Answer 1

3

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/

Sign up to request clarification or add additional context in comments.

2 Comments

To elaborate, the value of the key id in "columns" needs to be the same as the name of the key in "data".
gridjs sure takes camelCase/case sensitive seriously.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.