KoolReport's Forum

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

PivotTable: formatting fields/columns #75

Open bysystem opened this topic on on Aug 14, 2017 - 13 comments

bysystem commented on Aug 14, 2017

Hello,

in the widget Table:: I have the possibility to format each column and field by using label, align, decimal, decimalPoint properties (see below).

I tried the same in PivotTable:: but without any success!

Table::create(array(

"dataStore"=>$this->dataStore('sales_by_customer'),
    "columns"=>array(
        "customerName"=f>array(
            "label"=>"Customer"
        ),
        "dollar_sales"=>array(
            "type"=>"number",
            "label"=>"Amount",
            "prefix"=>"$",
        )
    ),

Any idea how to format for example the "price" values in a PivotTable for each summary field?

Kind regards

KoolReport commented on Aug 15, 2017

Before piping data to the Pivot process, please use the ColumnMeta to set the meta data for the measured field:

    ->pipe(new ColumnMeta(array(
      "dollar_sales"=>array(
        'type' => 'number',
        "prefix" => "$",
      ),
    )))
bysystem commented on Aug 15, 2017

I piped in my function setup() the corresponding CoulumnMeta before Pivot process as below, but unfortunately the result is still like 1,234 instead of 1.234,56 (see below the screenshot)

function setup()
{
	// MultiSelect-Optionswerte aus ETL.Werbegruppen holen
	$this->src('autorep')

... ...

    ->pipe($this->dataStore("Reporting.autorep_v_ProduktGruppen"));

... ...

	))
	->pipe(new ColumnMeta(array(
                "Umsatz"=>array(
	    "align"=>"right",
                "type"=>"number",
                "prefix"=>"",
	    "suffix"=>"",
	    "decimals"=>2,
	    "thousandSeparator"=>".",
	    "decimalPoint"=>",",
        )
	)))
	
	->pipe(new Pivot(array(
		"dimensions" => array(
		"column" => "Monat",
		"row" => "WerbegruppeVerbund, NikonKdName, NikonProdGruppe"
		),
		"aggregates" => array(
		"sum" => "Umsatz",
		//"sum" => "Umsatz, Verkaufsmenge",
	)
	)))
	->pipe($this->dataStore('Reporting.autorep_v_noNulls')); 
	//echo $this->params["Werbegruppe"];		
} 

KoolReport commented on Aug 15, 2017

I have made test and confirmed the issue. I will tell the developer of Pivot to find out the root issue as soon as possible.

KoolReport commented on Aug 15, 2017

I have just sent you the new Pivot.php file. Please replace the old file

bysystem commented on Aug 15, 2017

Thx a lot! Just replaced it and it works fine!

Only the property "align"=>"right" (cell alignment right in the table) seems not working!

Is there may be an other property for that?

KoolReport commented on Aug 15, 2017

The alignment has not been a feature of Pivot, we will add this ability probably in the next version of Pivot.

bysystem commented on Aug 15, 2017

OK understood. Thx a lot again!

bysystem commented on Aug 15, 2017

I would like to share my temporary solution for alignment:

I did it via CSS in the class:

.pivot-data-cell { text-align: right; }

KoolReport commented on Aug 15, 2017

Oh great! That is good solution.

Hallie Gromek commented on Aug 16, 2017

hi bysystem

Can you let me know if/how you have removed the Total Column from a pivot, I can't figure that out.

Any help is appreciated.

Thank you

bysystem commented on Aug 17, 2017

Hi Hallie,

in my screenshot above unfortunately you could not see the total row. So I did not removed it !

No idea how to remove it with the widget properties. But I assume you should be able to do it probably via CSSfor the dedicated row/column like style="display:none" ???

Hallie Gromek commented on Aug 23, 2017

Hi, I can't figure out how to add the css to the table data-column-index, tries alot of different ways.

Here's what I need to HIDE <td class="pivot-data-cell" data-row-index="0" data-column-index="3" data-layer="1">

Here's an example of my last try.

pivot-data-cell:nth-child(1) {

  background: red;

}

Any suggestions?

bysystem commented on Aug 25, 2017

Hi, may be you should upgrade to the new version 1.47 of koolreport (I did not test it yet). But in the chage log I saw one new feature:

  1. Enhancment: Ability to set cssStyle for each columns. cssStyle can be string or array containing components td,th and tf.

May be this helps!?

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
solved

Pivot