KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Koolreport + datatables: how to create a html url link using the data in a cell? #1955

Open Jeremy Gray opened this topic on on Mar 9, 2021 - 1 comments

Jeremy Gray commented on Mar 9, 2021

If in example below the first column is an incremental ID coming from mysqltable.id with value like 1,2,3,4,5,6,7,etc.

How do I make the cell render something like:

<a href="http://koolreport.com/example/$ID/page">$ID</a>

if array(0) value of mysqltable.id translates to "1" then link for first cell would be:

<a href="http://koolreport.com/example/1/page">1</a>

I did not find any examples of this on the forum or in koolreport examples.


  <?php
    DataTables::create(array(
        "dataSource"=>$this->dataStore("result"),
        "plugins" => ["Buttons"],
        "options" => array(

        "order" => [1, 'desc'],

        "paging"=>true,
        "searching"=>true,

        "columnDefs"=>array(
                array(
                "targets"=>array(0),
                "visible"=>true,
                "type"=>'num',
                ),
                array(
                "targets"=>array(1),
                "visible"=>true,
                "type"=>'',
                ),
       ),

            "dom" => 'Bfrtip',
        "pageLength" => 50,
        "lengthMenu" => [[50, 100, 500, -1],[50, 100, 500, "Show All"]],

            "buttons" => [
                        'excel','print','pageLength',
            ],

        ),
        "cssClass"=>array(
            "table"=>"table table-striped table-bordered"
        ),

        "searchOnEnter" => false,
        "searchMode" => "or"
    ));
    ?>
</div>

Sebastian Morales commented on Mar 10, 2021

Jeremy, pls try either of these methods:

1 . Use the "formatValue" property of DataTables' "columns" to format its value to a href:

https://www.koolreport.com/docs/datagrid/datatables/#format-column-value

2 . Use the "Map" process in report's setup to convert a column value to a href:

https://www.koolreport.com/docs/processes/map/

Let us know if we understand your question correctly. Tks,

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None