Using HTML in objects.txt file?

Using HTML in objects.txt file?

CalskinatorCalskinator Posts: 18Questions: 3Answers: 0

Is it possible to use HTML in the objects.txt file? I was able to use heading tags and paragraph breaks, but I can't seem to get an unordered list (UL) to work. Am I missing something or is that not possible? Thanks!

This question has an accepted answers - jump to answer

Answers

  • CalskinatorCalskinator Posts: 18Questions: 3Answers: 0
    edited September 2018

    I'd also like to use hyperlinks in the data file, too. If possible. Some of the data that displays in my table needs to be clickable. I have no clue how to accomplish this :/

  • CalskinatorCalskinator Posts: 18Questions: 3Answers: 0

    I found this but that doesn't help because I need to place the links in the objects file. Basically, my table will have 4,000 entries and each entry has a set of 5 to 20 links that need to be included. Not sure if this is possible!

    https://datatables.net/manual/tech-notes/8#Links

  • CalskinatorCalskinator Posts: 18Questions: 3Answers: 0
    edited September 2018

    OK now I figured out how to get links in the objects.txt file, but now my problem is... my links are designed to open JPGs in a shadowbox.

    My links look like this:
    [a href="img.jpg" rel="shadowbox[All-11k];width= 1000;height=1200"]

    I figured out how to get the link but I'm not sure how to get the rest of the code to work to open the links in the shadowbox. Not sure where to put it.

    I put the code here (see below) and it works to open the image, but it doesn't open in the shadowbox. If I create links outside of DataTables but on the same page, the links do open in the shadowbox, so I know the shadowbox code is correct (I have thousands of links and they all work). I'm just lost on how to translate this to DataTables.

            '<td><a href='+d.test+' rel="shadowbox[All-11k];width= 1000;height=1200">14</a></td>'+
    

    And of course in the objects.txt file I have defined test to be the image URL.

    There's a problem with that method, though, and it's that I need the link code to be in the txt file... because there are thousands of them and they each have a different anchor text. So, putting the code in my main page won't work because then all links would have the same anchor text.

    I'm forever grateful to anyone who can point me in the right direction! :)

  • CalskinatorCalskinator Posts: 18Questions: 3Answers: 0

    Shoot, I'd edit my previous comment but I can't apparently. This is how far I've gotten:

    In the objects.txt file, this is what my entry looks like:

      "test": "\"http://websiteaddress.com/image.jpg\" rel=\"shadowbox[All-11k];width= 1000;height=1200\">Page 16</a>"
    

    And on my HTML page, this is what my code looks like:

            '<td><a href='+d.test+'</td>'+
    

    The link to the image works perfectly but it just won't open in the shadowbox. I'm thinking it's because it's not picking up the shadowbox JS code from my header.

  • CalskinatorCalskinator Posts: 18Questions: 3Answers: 0

    I also checked with the shadowbox code and found in some cases I can't use "rel" so I set it up the other way as described here:

    http://www.shadowbox-js.com/usage.html#advanced

    And again all my links on the page outside of the DataTables table open in the shadowbox, but still, nothing inside the DataTables opens in the shadowbox.

    Sorry for all the individual comments, I'm on a mission to figure this out!

  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    Answer ✓

    Is it possible to use HTML in the objects.txt file?

    Yes. DataTables will render in the HTML tags.

    If you want to programmatically add HTML tags to items (e.g. links and images) then use columns.render. There is a details documentation page on the topic here.

    Allan

  • CalskinatorCalskinator Posts: 18Questions: 3Answers: 0

    Thanks Allan! I'm going to check it out in a bit :-D

  • CalskinatorCalskinator Posts: 18Questions: 3Answers: 0

    Well, I think I might need to hire someone to set this up for me so I can see what it needs to look like. Unfortunately, that's above my head, too. I never learned much Javascript at all, so I have no idea how to take that and translate it to what I need... without an example that applies to my situation. I can follow tutorials and examples and figure some things out but not very much. What would you suggest?

  • CalskinatorCalskinator Posts: 18Questions: 3Answers: 0
    edited September 2018

    Ok I switched my data source from Ajax to Javascript and was able to get it to work by skipping the Shadowbox initialization and assigning a class to my links and making all links in that class open in the shadowbox... that didn't work when I was using Ajax to source the data. Leaving this here in case anyone else has the same issue. Besides, I have like 4k data pieces, so I think using JS to source the data will be a heck of a lot easier... we'll see how well it works as I get it going! :)

This discussion has been closed.