1
想知道有人可以帮助我这个。csv html表与多个超链接
我使用这个例子CSV to HTML Table
我试图格式的追加列作为一个超链接,但老实说没有JS技能将不胜感激的任何援助。下面的例子显示了一列的代码。
<script>
//my custom function that creates a hyperlink
function format_link(link){
if (link)
return "<a href='" + link + "' target='_blank'>" + link + "</a>";
else
return "";
}
//initializing the table
CsvToHtmlTable.init({
csv_path: 'data/Health Clinics in Chicago.csv',
element: 'table-container',
allow_download: true,
csv_options: {separator: ',', delimiter: '"'},
datatables_options: {"paging": false},
custom_formatting: [[4, format_link]] //execute the function on the 4th column of every row
});
</script>
那究竟是什么问题?当你运行这段代码时你会得到一个错误吗? –
代码是完美的。我只是要求协助修改它以在csv中将2列格式化为超链接,而不是像例子中的1那样。希望有所帮助。谢谢回复。 我的csv数据有两个超链接数据字段,我需要将结果表格格式化为这样。 –
该文档说要使用数组的数组,所以它可能会是这样的:custom_formatting:[[4,format_link],[6,format_link]] - 我添加了一个额外的数组来格式化第6列中的链接 –