KoolReport's Forum

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

Add number column? #76

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

zenon commented on Aug 15, 2017

Hi,

I want to add a column that show the numbers accordingly,example from Table 1 to Table 2. Can this be done using KoolReport?

Appreciate your help. Thanks.

KoolReport commented on Aug 16, 2017

I will come back with an solution for this.

KoolReport commented on Aug 16, 2017

Hi,

I have sent you by email the updated Table to support the row number, to use please follow this example:

Table::create(array(
    "columns"=>array(
        "#"=>array(
            "label"=>"No",
            "start"=>1,
        ),
        ...
    )
))
zenon commented on Aug 17, 2017

I have checked my email but I didn't receive any attachment. Could you please send the updated Table again?

Thanks a lot.

KoolReport commented on Aug 17, 2017

I've sent you again! Please check

zenon commented on Aug 17, 2017

Yes. I've received. Thanks a lot.

zenon commented on Aug 25, 2017

Hi KoolReport,

How can I add the number column just like below?

I tried with Group but it just doesn't give what it should be. Thanks a lot.

KoolReport commented on Aug 25, 2017

Hi, you do:

"#"=>array(
    "start"=>0,
    "formatValue"=>function($value)
    {
        return $value%3+1;
    }
),
zenon commented on Aug 25, 2017

What if the numbering depends on the SQL statement result?

Appreciate your help.

KoolReport commented on Aug 25, 2017

I have not understood.

zenon commented on Aug 25, 2017

Let's say, based on the user input, the table I get is like Table 1 generated from the SQL statement.

However, I would like to add the number column as shown in Table 2, where the Department is numbered based on their Division.

If the user did not select any of the department, the numbering will vary. So, how to display the number column that can change according to the department selected by the user? Could this be done?

Appreciate your help.

Thanks a lot.

Anna Tolve commented on Dec 13, 2021

Hello, I use this code to display the row number, but I would like to know if there is a way to restart the count from 1 for each grouping?

   "columns"=>array(
	"#"=>array(
	"label"=>"N.",
	"start"=>1,
	"cssStyle"=>"text-align:right"
),
    ...
    "grouping"=>array(
	"PROV"=>array(...
	)
),
Sebastian Morales commented on Dec 14, 2021

Pls try to use "formatValue" function with $value and $row arguments like this:

$lastGroup = null;
Table::create(array(
    ...
    "columns" => array(
        "#"=>array(
            "start"=>0,
            "formatValue"=>function($value, $row) use (& $lastGroup)
            { 
                //use $row and $lastGroup to determine if this row contains a new group.
                //if new group reset $start = 1 else $start = $start + 1
            }
        ),

Let us know if you have any difficulty. Rgds,

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

None