KoolReport's Forum

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

Problems regarding table development #39

Open tee opened this topic on on Jul 27, 2017 - 7 comments

tee commented on Jul 27, 2017

Hi KoolReport,

Your help is kindly appreciated. From the table below, am i able to :

  1. Rearrange the sequence of column to be date at first, orange at second and apples at third column? How?

  2. Add % of oranges (oranges/total oranges*100%) for each date at column D and also show total oranges at C8? How?

  3. Add accumulated's column at column E to accumulate every oranges by date? How?

KoolReport commented on Jul 27, 2017

Could you please explain further the point 3. Please give me an example.

tee commented on Jul 28, 2017

For point 3, i want to have a column E names Accumulated as shown below. Calculation: (E3=75+84, E4=159+72 and so on). How can i do it in KoolReport? Appreciated.

KoolReport commented on Jul 28, 2017

Hi tee,

If you check your email then you will received 3 files: AggregatedColumn.php, Table.php and Table.tpl.php

Please do:

  1. Copy the AggregatedColumn.php into \koolreport\processes
  2. Replace Table.php and Table.tpl.php in folder \koolreport\widgets\koolphp

Now for your questions:

Problem 1: Arrange the date in first place, you simply set it at first in the columns settings of Table

Table::create(array(
    ...
    "columns"=>array("date","apples","oranges")
))

Problem 2: Total of oranges in Table at footer

Table::create(array(
    ...
    "showFooter"=>true,
    "columns"=>array(
        "date",
        "apples",
        "oranges"=>array(
            "footer"=>"sum",
        )
    )
))

Problem 3: Percentage of orange (This is interesting)

Now is when the AggregatedColumn to come in with purpose of creating new column "oranges_total" holding the total number of oranges. Then later we use the CalculatedColumn to create column called "oranges_percent". Last step is to show to oranges_percent in Table with percent mark.

Now in the setup we do:

->pipe(new AggregatedColumn(array(
    "oranges_total"=>array("sum","oranges")
)))
->pipe(new CalculatedColumn(array(
    "oranges_percent"=>"{oranges}*100/{oranges_total}"
)))
->pipe($this->dataStore("mydata"));

In the view we do:

Table::create(array(
    "columns"=>array(
        "date",
        "apples",
        "oranges",
        "oranges_percent"=>array(
            "type"=>"number"
            "suffix"=>"%",
        )
    )
))

Problem 4: Accumulated columns

Again, we will use the AggregatedColumn to calculated

->pipe(new AggregatedColumn(array(
    "oranges_accumulated" =>array("acml","oranges")
)))

Now you have the accumulated column "oranges_accumulated"

All the best!

zenon commented on Jul 29, 2017

Hi KoolPHP Inc, Instead of displaying the total of oranges in Table at footer, is it possible to display the total at the first row of the table?

Thanks.

KoolReport commented on Jul 29, 2017

You can define this css style on your own:

<style rel="stylesheet">
    tfoot
    {
        display: table-row-group;
    }
</style>

Updated: Hmm, I've tested above code but not working yet, so I guess I will come back later with solution.

KoolReport commented on Jul 29, 2017

We have come up with solution:

Table::create(array(
    "showFooter"=>"top",
    ...
))

However, if you need the solution now, please email to support@koolreport.com, I will send you the updated Table widget.

zenon commented on Aug 1, 2017

KoolPHP Inc,

Is it possible to show sum both at the footer and top?

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
wiki
help needed

None