Displaying text data as a URL instead
Displaying text data as a URL instead
matthean
Posts: 10Questions: 3Answers: 0
Lets say I have data field covering a record, ie id, title, date, description, etc.. I am trying to display that data, but I also want the ID number to be a URL so a user can click on the ID number and go to the record itself. I feel like I went through the manual enough and didn't really see the option to do it. Is it actually possible?
Answers
Use
columns.render
to display a URL containing the ID number. See the forth example in the docs. You may just want to generate the URL for thedisplay
operation. Similar to the fifth example. See the Orthogonal data docs for more details.Kevin
I went and modified the code. I'm getting no errors with the code and yet all I get is just the ID displayed.
That looks like it should render a link tag correctly. Can you link to your page so I can take a look at it please?
Thanks,
Allan
It is being done via an internal site for a client, so there is no way to link it. Here's the complete column definition.
ID
is undefined there. Use:since the value from the
ID
parameter will be passed in to the rendering function as thedata
parameter.Allan
I copied your code snippet into this test case and it seems to be working:
https://live.datatables.net/dodobuge/35/edit
Although the link doesn't work, the name is being displayed as clickable a URL. Can you update the test case to show the issue you are having?
Are you expecting something more than the ID to be displayed? If so what do you expect to see?
Kevin
I changed ID in the URL to data, and I still just get the plain text ID number. I do an inspect and all I see is the ID in text.
I need a link with the ID so someone can click on it and have it go to a page where I can display just that record.
I took your code snippet and showed that it works in the above test case:
https://live.datatables.net/dodobuge/35/edit
Maybe the change to
data
is being loaded an you need to clear the browser's cache. Place a break point in thecolums.render
function to see what is happening.To help debug we will need to see a page that replicates the issue. Can you post a link to a test case that shows the issue?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin