KoolReport's Forum

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

Column alignment? #353

Open Jure Zakrajsek opened this topic on on Jul 5, 2018 - 3 comments

Jure Zakrajsek commented on Jul 5, 2018

Is there a way to align different columns in the datagrid package? I would like some columns to center or right align.

Thx for the help Jure

KoolReport commented on Jul 5, 2018

You do following this example:

DataTables::create(array(
    ...
    "cssClass"=>array(
        "td"=>function($row,$colName)
        {
            if ($colName=="officeCode")
            {
                return "text-center";
            }
        },
        "th"=>function($colName)
        {
            if ($colName=="officeCode")
            {
                return "text-center";
            }
        },
    )
));

Above example will make all "officeCode" column align to center.

Please let me know if you need further assistance.

Jure Zakrajsek commented on Jul 7, 2018

Is it possible to do this for a list of columns. I dont seem to get the in_array function to work it returns an empty page.

    "td"=>function($row,$colName)
    {
        if (in_array($colName, array("column1","column2","column3"))
        {
            return "text-center";
        }
    },

Thx

David Winterburn commented on Jul 9, 2018

Hi Jure,

I think your code lack one right parenthesis at the end of the if line so it's a PHP syntax error.

Please turn on error reporting for your PHP page so you know the line that cause error.

Please also use a coding editor (says Vistual Studio Code or Notepad++) which could show syntax error even before you run a page.

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