How to show image and url?
How to show image and url?
TotallyNotDaniel
Posts: 3Questions: 1Answers: 0
Sorry ahead of time but I'm kinda new to all of this. Using the code from this site I made the thing to read my stuff and everything worked. However, I tried to change it to display some extra stuff like images and url format and everything broke. Any help would be appreciated.
Also I don't know how the test case thing works I'm running out of google scripts and the deployment is a blank page.
<script>
google.script.run.withSuccessHandler(showData).getData();
function showData(dataArray){
$(document).ready(function (){
$('#data').DataTable({
columns: [
{"title": "Title"},
{"title": "Year"},
{"title": "Authors"},
{"title":"Link",
"render": function(data, type, row, meta){
if(type == 'display'){
data = '<a href="' + data + '">' + data + '</a>';
}
return data;
}
},
{"title":"Cover",
"render": function(data, type, row, meta){
if(type == 'display'){
data = <img src="data" alt="Cover" width="500" height="600">
}
return data;
}
}
],
});
});
}
</script>
Answers
In line 22 it looks like you are missing quotes around the string. You will probably see some sort of syntax error in the browser's console. It should look like this:
Kevin
Hmm i changed my code to look the same as yours yet it still doesn't work. I looked at some stuff and they seem to use data to describe columns instead of a title. Could that be causing the issue or should I look for something else?
dunno how much this wouldhelp but here's like all my code.
gs code:
index.html
js w/ datatable
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