KoolReport's Forum

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

Collapsing some rows and columns #668

Open Eugene opened this topic on on Feb 12, 2019 - 7 comments

Eugene commented on Feb 12, 2019

Hi, Koolreport,

Is it possible to create something like this using the pivot or something else? It is not clear pivot because there is not sum or count rows/colums but I need to collapse some rows and columns

David Winterburn commented on Feb 12, 2019

Hi Eugene,

Our pivot table couldn't show the exact format as your picture describes but you could make a similar one:

->pipe(new Pivot(array(
      "dimensions"=>array(        
        "row"=>"date, name, item_name",
      ),
      "aggregates"=>array(
        "sum"=>"used_quantity, rec_quantity, deviation, cost",
      ),
    )))
->pipe($this->dataStore('sales'));  
$dataStore = $this->dataStore('sales');
          PivotTable::create(array(
            "dataStore"=>$dataStore,
            'rowCollapseLevels' => array(1),
            'showDataHeaders' => true,
          ));

Hope it meets your demand. Thanks!

Eugene commented on Feb 12, 2019

Thank you David, it is almost what I need but is it possible to hide some total amounts? For example, sum amounts for quantities and deviations are useless in my case. I understood you do like that to have the possibility to collapse them but is it possible to hide the sum amount for these columns?

Eugene commented on Feb 14, 2019

Sorry just to up this topic I am really interested in is it possible to control the visibility of the selected cells.

Eugene commented on Feb 18, 2019

up :-(

KoolReport commented on Feb 18, 2019

May be this will help. Those properties allow you to hide the grand total/sub total columns/rows,

Eugene commented on Feb 18, 2019

Unfortunately no, because I need to hide not a whole row but 3 cells only I thought it is possible to do using CSS selectors, but I could not find the correct ones.

David Winterburn commented on Feb 19, 2019

Hi Eugene,

Please try some map function like this:

PivotTable::create(array(
...
	'map' => array(
		'dataCell' => function($value, $cellInfo) {
			$isDevSumCol = $cellInfo['fieldName'] === 'dev - sum';
			$isDateTotalRow = isset($cellInfo['row']['date']['total']);
			$isNameTotalRow = isset($cellInfo['row']['name']['total']);
			$hide = $isDevSumCol && ($isDateTotalRow || $isNameTotalRow);
			return $hide ? '' : $cellInfo['formattedValue'];
		},
	),
...
));

Hope this helps. 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

None