KoolReport's Forum

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

Table header to table data #69

Open zenon opened this topic on on Aug 10, 2017 - 12 comments

zenon commented on Aug 10, 2017

Hi,

Could you please show me how to do this? (From Table 1 to Table 2)

Appreciate your help.

KoolReport commented on Aug 10, 2017

It is possible but will require a new process to transpose the data table. I will keep you update on this.

zenon commented on Aug 25, 2017

Hi,

I noticed that the new version has the transpose process.

Could you please guide me on how to display the table as shown above?

Appreciate your help.

Thanks a lot.

zenon commented on Aug 28, 2017

Hi,

Sorry to disturb. But could you please show me how to use the transpose process to display such table?

Your help is much appreciated.

Thanks a lot.

KoolReport commented on Aug 28, 2017

Hi, I am sorry for late reply on this. The use of Tranpose process is simple, you just do:

->pipe(new Transpose())

This will change row to column and vice versa. The new columns will be name "c0", "c1" to "cn"

zenon commented on Aug 28, 2017

Hi,

Can the transpose process work after selecting the column I want from the original table?

<?php
        Table::create(array(
        "dataStore"=>$this->dataStore('report'),
        "columns"=>array(
            "a"=>array("decimals"=>2),
            "b"=>array("decimals"=>2),
            "c"=>array("decimals"=>2),
            "d"=>array("decimals"=>2)
            ),
        "cssClass"=>array(
            "table"=>"table table-bordered table-condensed",
        ),

        "removeDuplicate"=>array("a", "b", "c", "d")
    ));
?>

I want to transpose the output from the above code.

Could this be possible?

KoolReport commented on Aug 28, 2017

No, the Tranpose process should be use in the setup() function. It is better that you prepare the data then transpose it, save it to a datastore then use table to display tranposed data.

hsw commented on May 9, 2019

Hi,

My data is stored in this way: name, category, description, ratey1, ratey2, ratey3

I need a Table report to look like this:

I suppose I can use Transpose process in the setup() function to switch my data to column, and store in datastore. I am not able display the transposed data somehow. How do I define the report columns so as to display the transposed data?

David Winterburn commented on May 10, 2019

Hi,

Would you please post your php code and describe what's wrong with the result (with screenshot or error message if possible)? Thanks!

hsw commented on May 10, 2019

Hi,

Report 1 is without Transpose process.

Report 2 is with Transpose process.

The php codes for the 2 Reports are exactly the same, except the Transpose() process was added for Report 2. I am trying to figure out how to define the Columns for the Table display.

Here is the php code:with Transpose process:

    protected function setup()
    {
        $this->src('packages')
        ->pipe(new Filter(array(
			array("category","=","Fixed Rate"),
			array("activeflag","=","Y"),
        )))
        ->pipe(new Sort(array(
            "ratey1"=>"asc",
			"ratey2"=>"asc",
			"ratey3"=>"asc",
        )))
        ->pipe(new Limit(array(5)))
        ->pipe(new Transpose())
	->pipe($this->dataStore('basic_dataout'));
    }

Here is the php code for displaying the Table:

<?php
	Table::create(array(
        "dataStore"=>$this->dataStore('basic_dataout'),
            "columns"=>array(
                "package_id"=>array(
                    "label"=>"Package ID"
                ),
                "bank"=>array(
                    "label"=>"Bank"
                ),
                "category"=>array(
                    "label"=>"Category" 
				),
				"name"=>array(
                    "label"=>"Description"
                ),
				"ratey1"=>array(
                    "label"=>"Year 1 Rate"
                ),
				"ratey2"=>array(
                    "label"=>"Year 2 Rate"
                ),
				"ratey3"=>array(
                    "label"=>"Year 3 Rate"
                ),
            ),
        "cssClass"=>array(
            "table"=>"table table-hover table-bordered"
        )
    ));
?>

Thank you

David Winterburn commented on May 11, 2019

Hi,

Would you please post all php code of your report 1 & 2 (including setup and view files) for us to check them for you. Thanks!

hsw commented on May 11, 2019

Hi,

Please allow me to re-phrase my question.

My data in csv file looks like this:

Using kookreport, I am able to output a report (Table) that looks like this:

My question is how can I output a report (Table) that looks as follows. Instead of rows, the records are output in columns.

Thank you

hsw commented on May 12, 2019

Hi.

Sorry, please ignore my last post.
I managed to figure out how the Transpose process work. I realised I have to define the columns as c0, c1, c2, c3, c5 in the view.php file.

Thank you

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