How do I render images depending on the row?

How do I render images depending on the row?

JohannesRJohannesR Posts: 2Questions: 2Answers: 0

So I need to render images, but since I don't know the row and therefore not the src/image row xxx will have, I need to it dynamically. I already have the source of the pictures (created dynamically) as cell text, but can I use that variable in my html tag?

Here is my code snippet:

columns: [
{ title: "Angle [°]" },
{
title: "Bild",
data: "nozzle_picture.png",
targets: 0,
render: function ( url, type, full) {
return '<img height="130" width="130" src="..."/>';
}
}
]

src="..." should be the variable path. After a search on the web, I only found something like document.getElementById('.....').src, but I can't use this for datatables, can I?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.