KoolReport's Forum

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

Control over Cube view #748

Closed Eugene opened this topic on on Mar 17, 2019 - 4 comments

Eugene commented on Mar 17, 2019

Hi, Below you can find the result of my cube process

Everything is ok but I would like to have a bit more control over the widget.

The problem is that the number of columns (dates) is variable and depend on the report parameter. So I can not set these columns in the Table widget as I do it usually using the "column" properties
How could I

  1. move the Total ({all}) column to the end of the table
  2. align text in date columns
  3. hide the date columns using a checkbox (sure I can add some logic and create 2 tables - one with the total column only and show only one of the tables depending on the checkbox state) but maybe there is a more elegant way?
David Winterburn commented on Mar 18, 2019

Hi Eugene,

In your view file of your report, I think you could retrieve the list of the columns of any datastore generated by the Cube process. Here's an example of setting the columns' css style:

//MyReport.view.php
<?php
$columnsMeta = $this->dataStore('salesCube')->meta()["columns"];
$columnNames = array_key($columnsMeta);
$columnSetting = [];
foreach ($columnNames as $colName) {
    if ($colName !== "{{all}}" {
        array_push($columnSetting, array(
            $colName => array(
                "cssStyle" => "text-align: right",
            )
        ));
    }
}
Table::create(array(
    "dataSource" => $this->dataStore('salesCube'), 
    "columns" => $columnSetting,
));
?>

Similarly, you could choose to display certain columns or not now that you have had their names.

Eugene commented on Mar 19, 2019

Thank you David, I understood your idea but I met some problem Below is what I get (I have also changed a typo in array_keys), the $columnSetting looks also correct but the result is not that is expected

David Winterburn commented on Mar 19, 2019

Hi Eugene,

My bad, please change the following lines:

        array_push($columnSetting, array(
            $colName => array(
                "cssStyle" => "text-align: right",
            )
        ));

to:

        $columnSetting[$colName] = array(
            "cssStyle" => "text-align: right",
        );

Let us know if it works for you. Thanks!

Eugene commented on Mar 19, 2019

Yes, I've found it also already. 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
solved

None