Give hyperlink on image column in data table

Give hyperlink on image column in data table

ayesha@4ayesha@4 Posts: 2Questions: 1Answers: 1

i have one data table,on loading of data table i need to show some images based on some values in one column..and at the same time onclick of that column i need to change that image..it's like falg an dimportant columns in our gmail..At present iam able to show images based on some conditions using "render: getStarredflag,".But on that same column i need to give hyperlink also on click of which we need to update db and change the image.

This is what i have tried,sample code.How to give hyperlink and call test() function onclick of that image column.??

`Getmaildetailstable = $('#Getmaildetailstable').DataTable({
columnDefs: [{
orderable: false,
className: 'select-checkbox',
defaultContent: "",
targets: 0,
visible: false
}, {
data: "image",render: getStarredflag,
defaultContent: "",
targets: 6,
visible: true
}
order: [
[2, 'asc']
],
"searching": false,
"lengthChange": true
});

         function getStarredflag(data, type, full, meta) {
        var starflag=full.STARRED_FLAG; 
        if(starflag=="1")
        {
        return '<img src="wcp/theme/default/icon/action/star_icon1.png" />';
        }
        else if(starflag=="0")
        {
        return '<img src="wcp/theme/default/icon/action/star_yellow.png" />';
        }
      }
      function test()
      {
          alert("test");
      }`

This question has an accepted answers - jump to answer

Answers

  • ayesha@4ayesha@4 Posts: 2Questions: 1Answers: 1
    Answer ✓

    It has been solved...
    code modified like this..

    if(starflag=="1"){
    return '<img src="wcp/theme/default/icon/action/star_icon1.png" onclick="test()" />';
    }

This discussion has been closed.