DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:datatables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Both sides next revision
plugin:datatables [2020-11-18 12:57]
robl [Suggestion: autolink]
plugin:datatables [2020-11-18 13:04] (current)
robl [Suggestion: autolink]
Line 178: Line 178:
 One possible answer to the above is to modify the SQL query so it outputs a link. One possible answer to the above is to modify the SQL query so it outputs a link.
  
-  * To make a link clickable (where the thing returned from sql is already a URL, in field "url"):+  * To make a URL clickable (where the thing returned from sql is already a URL, in field "''url''"):
  
 <code> <code>
 <sql> <sql>
-CONCAT('<a href="',table.url,'" target=_blank">',table.url,'</a>') AS url,+SELECT 
 + CONCAT('<a href="',table.url,'" target=_blank">',table.url,'</a>') AS url, 
 +... 
 +FROM 
 +    table
 ... ...
 </sql> </sql>
 </code> </code>
  
-For example, if you wanted to make "id" a clickable link like:+To make "''id''in table "''table''" part of a clickable link:
  
-  * To put the id at the end of the link: ''https://my.website.here/100''+  * To put the id at the end of the link, e.g.: ''https://my.website.here/100''
  
 <code> <code>
 <sql> <sql>
-CONCAT('<a href="https://my.website.here/',table.id,'" target=_blank">',table.id,'</a>') AS id,+SELECT 
 + CONCAT('<a href="https://my.website.here/',table.id,'" target=_blank">',table.id,'</a>') AS id, 
 +... 
 +FROM 
 +    table
 ... ...
 </sql> </sql>
 </code> </code>
  
-  * To insert the id somewhere in the link: ''https://my.website.here/100/details''+  * To insert the field ''id'' somewhere in the link, e.g.: ''https://my.website.here/100/details''
  
 <code> <code>
Line 204: Line 212:
 SELECT SELECT
     CONCAT('<a href="https://my.website.here/',table.id,'/details" target="_blank">',table.id,'</a>') AS id,     CONCAT('<a href="https://my.website.here/',table.id,'/details" target="_blank">',table.id,'</a>') AS id,
 +...
 +FROM
 +    table
 ... ...
 </sql> </sql>
 </code> </code>
 +
 +And other variations on this, for example if you needed multiple fields to build the URL, that's possible too with ''CONCAT''.
  
 Obviously this hack is only useful if you're using datatables with the sql plugin. It also means you can't do "''SELECT *''" because you need to modify the correct field. Obviously this hack is only useful if you're using datatables with the sql plugin. It also means you can't do "''SELECT *''" because you need to modify the correct field.
plugin/datatables.txt · Last modified: 2020-11-18 13:04 by robl