How to display links in table

How to display links in table

neilstampsneilstamps Posts: 2Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
I wish to migrate an existing table structure to datatables. The links are of the type:

<g:link title="Warnings" controller="actionController" action="viewWarning" id="${request.id}">
<img src="<fam:icon name="error"/>" />
</g:link>
<g:link title="History" controller="actionController" action="viewHistory" id="${request.id}">
<img src="<fam:icon name="magnifier"/>" />
</g:link>

I have tried constructing a render instruction, however the concatenation seems to not work correctly. Can someone please advise a way forward for this. Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    What does the resulting HTML look like? I don't know what a <g:link> tag does in this context.

    Allan

  • rostrost Posts: 26Questions: 9Answers: 1
    Answer ✓

    For me rendering links works using this:

              {
              "data": "NameOfField",
              "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                if(oData.NameOfField !== null && oData.NameOfField !== '') {
                  $(nTd).html("<a href='"+oData.NameOfField+"' target='_blank'>Link</a>");
                }
              }
            },
    
  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    Yep, that's a good way to go, you can also use columns.render,

    Colin

  • neilstampsneilstamps Posts: 2Questions: 1Answers: 0

    Thanks for the help the .html seems to do the trick

This discussion has been closed.