Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Images in react datatables

viperovm free asked 4 years ago


Hi!

How can I use images in datatables?

Way like this doesn't work:

data: {
    columns: [],
    rows: [
    {
      avatar: <img src{data.personal_info.avatar} alt={data.personal_info.last_name}/>
      ...
    }
    ]
}

Krzysztof Wilk staff answered 4 years ago


Hi!

Everything should work as you did it.

Firstly - add some columns. Without columns, there are no row cells. Secondly - the image should be declared as:

avatar: <img src='https://mdbootstrap.com/img/new/slides/041.jpg' />

or

avatar: <img src={data.personal_info.avatar} />

In the first example, I used an example image - you can check if it works for you. If something doesn't work - I assume there's a problem with your path property.

Best regards



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.26.1
  • Device: Macbook
  • Browser: Chrome
  • OS: MacOS 11
  • Provided sample code: No
  • Provided link: No