KoolReport's Forum

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

Displaying data in table as Yes or No #1864

Open Richb201 opened this topic on on Jan 25, 2021 - 1 comments

Richb201 commented on Jan 25, 2021

I have a field, consultant, in my mySQL table which is either 0 or 1. I'f like to display this on the Table row as either Yes or No. How can I set this up?

<?php
Table::create(array(
    "dataStore"=>$this->dataStore("ThreeWayRiskAnalysis")->filter("taxyear","=",$_SESSION['last_TY']),
    "showFooter"=>true,
    "columns"=>array(
        "employee",
        "title",
        "wages"=>array(
                "cssStyle"=>"text-align:right",
                "prefix"=>"$",
                "footer"=>"sum",
                "footerText"=>"<b>Total Wages:</b> @value"
            ),
        "risk",
        "consultant",
        "QREs"=>array(
            "cssStyle"=>"text-align:right",
            "prefix"=>"$",
            "footer"=>"sum",
            "footerText"=>"<b>Total Wages Qualified:</b> @value"
        )
    ),
    "cssClass"=>array(
        "table"=>"table-bordered table-striped table-hover"
    )
));

?>
KoolReport commented on Jan 25, 2021

You can do:

"consultant"=>array(
    "formatValue"=>function($value) {
        return ($value==1)?"Yes":"No";
    }
)

Reference: Table Format Column Value

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