KoolReport's Forum

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

DataGrid renderer #270

Open Michael Wenleder opened this topic on on May 7, 2018 - 3 comments

Michael Wenleder commented on May 7, 2018

Hello everyone,

currently I am using data tables natively. Is there any way to use renderers within DataGrid?

Example:

Thanks in advance!

KoolReport commented on May 9, 2018

Sorry for my late reply, if you use the DataTables in DataGrid package, you can use the "formatValue" to return an html that you want, for example:

DataTables::create(array(
    "columns"=>array(
        "myColumn"=>array(
            "formatValue"=>function($value,$row)
            {
                if($value=="pos")
                    return "<center><img src='...' /></center>";
            }
        )
    )
))
Michael Wenleder commented on May 11, 2018

Thank you very much - it does work perfectly :-)

Michael Wenleder commented on May 11, 2018

What I am missing is the possibility to tell the formatter to only format for type == display:

"render": function (data, type, row, meta) {
        if (type === 'display') {

For example if I have numbers for days. And I want to use the formatter to color all numbers from 0 - 30 in green, all in 30 - 90 in yellow and all above in red. With the original DataTables I use the type === display comparison to ensure that sorting is still possible based on the integer value. If I use DataGrid I could not find an option to avoid a miss functional sorting.

Do you have any solution for this issue?

Thanks!

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

DataGrid