Fetch row index while initialise

Fetch row index while initialise

opher50opher50 Posts: 2Questions: 1Answers: 0

Hey Guys,

I'm trying to build an image in each row, based on the data index.
So essentially - I have an array where one of the fields has an image path "/images/...png" and i'm trying to push in the DataTable default content an image tag with the path, unsuccessfully.

Tried many things with no solution, would really appreciate some help!

'''
var table = $('#issues').DataTable();

var issues = <?php echo json_encode($reportedissues)?>;
var images_path = table.row($(this)).data();
alert(images_path);

$('#issues').DataTable( {
    data: issues,
    scrollY:        '70vh',
    scrollCollapse: true,
    paging:         false,
    pageResize: true,
    columnDefs: [ {
        "targets": -1,
        "data": null,
        "defaultContent": "<image src='"+issues["INDEX"][5]+"' style='width: 150px; height: 150px'></image>"
    },
        {"className": "dt-center", "targets": "_all"}
    ],
    order: [[ 0, "desc" ]]
} );

$('#issues').on( 'init.dt', function () {
    alert( 'Table redrawn' );
} );

'''

Thanks!

Answers

  • opher50opher50 Posts: 2Questions: 1Answers: 0

    Solved!

    Used render function instead!

This discussion has been closed.