Ayesha Fathima

Ayesha Fathima

  • NA
  • 184
  • 28k

Give hyperlink on image column in data table

Feb 7 2018 4:46 AM
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.??
  1. Getmaildetailstable = $('#Getmaildetailstable').DataTable({  
  2.                  columnDefs: [{  
  3.                      orderable: false,  
  4.                      className: 'select-checkbox',  
  5.                      defaultContent: "",  
  6.                      targets: 0,  
  7.                      visible: false  
  8.                  }, {  
  9.                      data: "image",render: getStarredflag,  
  10.                      defaultContent: "",  
  11.                      targets: 6,  
  12.                     visible: true  
  13.                  }  
  14.                  order: [  
  15.                      [2, 'asc']  
  16.                  ],  
  17.                  "searching"false,  
  18.                  "lengthChange"true  
  19.              });  
  20.                
  21.              function getStarredflag(data, type, full, meta) {  
  22.             var starflag=full.STARRED_FLAG;  
  23.             if(starflag=="1")  
  24.             {  
  25.             return '<img src="wcp/theme/default/icon/action/star_icon1.png" />';  
  26.             }  
  27.             else if(starflag=="0")  
  28.             {  
  29.             return '<img src="wcp/theme/default/icon/action/star_yellow.png" />';  
  30.             }  
  31.           }  
  32.           function test()  
  33.           {  
  34.               alert("test");  
  35.           }  

Answers (1)