KoolReport's Forum

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

How to set up hyperlinks within tables? #729

Closed Markus Mohr opened this topic on on Mar 6, 2019 - 2 comments

Markus Mohr commented on Mar 6, 2019

KoolReport 3.25.4.

Beside chart- and table-based data analysis, for some evaluations I also deliver error lists which denote important data missing ("missing values") for various reasons (the reasons usually are coded as numbers (error codes)).

Such a list may look like this:

The green arrow denotes the patient ID column.

How can I make each patient ID hyperlinked (so that once clicking on such an ID a window with this patient's specific data is opened and her / his data can be replaced or substituted)?

Does my error list have to include a calculation for instance in the following way:

[...]
			       	       ->pipe(new CalculatedColumn(array(
                                            "PatientID"=>array(
                                                "label"=>"PatientID",
                                                "exp"=>function($row)
                                                {
			                            $link = "../site.php?patientID=" . $row['PatientID'];
                                                    $row['PatientID'] = "<a target=\"_parent\" href=\"{$link}\">";
                                                    return $row['PatientID'];
				                },
				                "type"=>"string"
                                            ),
				            "surgeryDuration"=>array(
						"label"=>"OP-Dauer",
				                "exp"=>function($row)
				                {
				                    if ($row["surgeryDuration"] == 1000)
				                    {
				                        $row["surgeryDuration"] = "Noch nicht dokumentiert";
				                        return $row["surgeryDuration"];
				                    }
				                    else
				                    {
				                        return $row["surgeryDuration"]."-".($row["surgeryDuration"]+15);
				                    }
				                },
				                "type"=>"string"
				        ))))
[...]

However, the code ...

			                            $link = "../site.php?patientID=" . $row['PatientID'];
                                                    $row['PatientID'] = "<a target=\"_parent\" href=\"{$link}\">";
                                                    return $row['PatientID'];

... only leads to the following result (irrelevant of whether "type" is set to "string" or "number"):

So, maybe it is only a question of how to set the single or double quotes?

KoolReport commented on Mar 7, 2019

There are number of topic on forum mentioned about this, basically you use the "formatValue" for PatientID column:

Reference:

  1. How to create master detail report?
  2. Hyperlink in table?

Documentation:

Format Column Value

Hope that helps.

Markus Mohr commented on Mar 7, 2019

Very well, the references helped me a lot.

With ...

			        "columns"=>array(
			            "PatientID"=>array(
				            "formatValue"=>function($PatientID)
				            {
				                return "<a target='_parent' href='../../site.php?patientID=$PatientID'>$PatientID</a>";
				            },
					   "cssStyle"=>array(
				                "th"=>"background-color:#1E1D0B;color:#CC9600;text-align:left;font-size:18px;"
				            )
			            ),

... everything works like a charm:

Thank you very much.

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
solved

None