KoolReport's Forum

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

Show custom label on hyperlink #888

Open paulo opened this topic on on May 24, 2019 - 2 comments

paulo commented on May 24, 2019

Hi, I have a searchable report that shows the id so I can have a hyperlink to the record. How can I replace the ID label with a custom value from the database i.e. name of the record and still link to the id ? '>@value</a> <- replace this with the name of the tour i.e. tourname thank you <a href='https://my.ellisontravel.com/tour/tours/@value'>@value</a>

<?php

DataTables::create(array(
    "dataSource"=>$this->dataStore("searchabletours"),
    "options"=>array(
        "searching"=>true
    ),
    "columns"=>array(
        "tourid"=>array(
            "type"=>"text",
            "label"=>"id",
            "formatValue"=>"<a href='https://my.ellisontravel.com/tour/tours/@value'>@value</a>"
        ),
        "tourname"=>array(
            "type"=>"text",
            "label"=>"Tours"
        ),
        "planner",
        "CountryName",
        "startDate",
        "endDate",
        "insurance_number"

    )
));
David Winterburn commented on Jun 4, 2019

Hi Paulo,

Sorry for the late reply! Regarding your question, the "formatValue" could be a function with the column and row values as arguments from which you could build your link:

 "columns"=>array(
        "tourid"=>array(
            "type"=>"text",
            "label"=>"id",
            "formatValue"=> function($value,$row) {
                $tourID = $value; // or = $row["tourid"];
                $tourName = $row["tourname"];
                return "<a href='https://my.ellisontravel.com/tour/tours/$tourID'>$tourName</a>";
            },
        ),
...

Hope this helps. Thanks!

paulo commented on Jun 4, 2019

thank you very much. This worked perfectly.

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
help needed

None