简体   繁体   中英

How do I return multiple values from render function in Datatables?

My knowledge in Javascript is quite poor and my question may appear a bit stupid. Anyway, here we go: I have a column in Data-tables that fetches URLs from a MySQL database.The URLs points to images stored elsewhere. I use render function to do the job(see code below) as I can´t target the integer of the column(as it differs due to being situated in a hidden responsive child row)). That works fine. Now I also want to add my own CSS to the image in the row.

How can I add this to my js below?

{ "data": "img",
  className: "min-phone",
  "render": function ( data, type, row) {
                return '<img src="http://beginning.of.url.to.image' + data + '" />';
           }
 }

You can use css class to get around this problem.

Based on the device you can add css class like below.

return '<img src="http://beginning.of.url.to.image' + data + '" class="medium-screen" />';

or

return '<img src="http://beginning.of.url.to.image' + data + '" class="large-screen" />';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM