Hyperlink
Hyperlink
Link to test case: http://live.datatables.net/muyemace/188/edit
Description of problem: Is there a way to show the data in a column as hyperlinks? I want the "google.com" in my column Hyperlink to be clickable and direct me to that URL.
This question has accepted answers - jump to:
Answers
Hi
Perhaps try
@Lapointe That works fine, it's just that I get my data from a database and don't have hardcoded data in my rows. (I should have specified that).
I am working with a SQLite database and get my data from there and with a for loop I get each row. Is there a way to set a column data type to "url/hyperlink"?
Use
columns.render
. The docs show an example.Kevin
@kthorngren Thanks, that works really well.
With
I was able to display the url and not just "Download"
Another related question: Since I have multiple urls in one cell, I named them.
For example www.google.com (Google Webpage) www.facebook.com (Facebook Webpage).
Is there a way to only show the real urls as hyperlinks and the description as normal text? I could always implement a new column and have the names there but that wouldn't be perfect and also even without the names multiple urls are handled as one and don't work properly, is there a way to put multiple urls in one cell and have seperate.
Is this all one string? If so you will need to parse the string, ie
data
, to split out the url from the text to display the way you want.If you need help please provide a simple running test case that shows an example of your data. This way we can see exactly what you have to offer suggestions.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
@kthorngren Hey Kevin.
Test case: http://live.datatables.net/muyemace/193/edit
It would look something like this if you would look at the "Hyperlink" for Ashton Cox.
Based on your sample data of
google.com (Google Webpage) facebook
andgoogle.com
you can do something like this example:http://live.datatables.net/muyemace/194/edit
You will notice it doesn't work for fields you didn't update with your example data. You might need to adjust the string parsing to fully match your data and the output you want. Use Stack Overflow for ideas of how to parse your strings.
Kevin
@kthorngren Thanks Kevin. That actually works for some of the urls. I have some urls that have an empty space in the url (not web url, path to some folders) which leads to problems I think.
I will look into parsing the strings.