Get KoolPHP UI with 30% OFF!

Pivot sum field headers

Kelly
I've added three sum fields to my pivot table. Each one says something like
"Sum of 2014-01-01"
Is there a way to modify the header to just say "cost", "amt_due", or "leads”?
(The Add Image control in the forum editor does not work.)
cost amt_due leads | franchise date
--------------------------------------------------------------
catetory type campaign | franchise1
| date1 date2 date2
| Sum of date1 | Sum of date1 | Sum of date1 <---- I'd like these to say "cost Sum of date1" "amt_due Sum..." "leads Sum..."
CODE minus top part...
    $pivot = new KoolPivotTable("pivot");
    $pivot->scriptFolder = $KoolControlsFolder ."/KoolPivotTable";
    $pivot->styleFolder = "office2007";
    $pivot->DataSource = $ds;
	//Turn on ajax features.
	$pivot->AjaxEnabled = true;
	//Set the Width of pivot and use horizontal scrolling
	//$pivot->Width = "1200px";
	$pivot->HorizontalScrolling = true;
	//Set the Height of pivot and use Vertical Scrolling
	//$pivot->Height = "1000px";
	$pivot->VerticalScrolling = true;
	//Allow filtering
	$pivot->AllowFiltering = true;
	//Allow sorting
	$pivot->AllowSorting = true;
	//Allow reordering
	$pivot->AllowReorder = true;
    $pivot->Pager = new PivotPrevNextAndNumericPager();
    $pivot->Pager->PageSize = 30;
    $pivot->AllowCaching = true;
    $field = new PivotSumField("cost");
    $field->FormatString = "\${n}";
    $pivot->AddDataField($field);
    $field = new PivotSumField("amt_due");
    $field->FormatString = "\${n}";
    $pivot->AddDataField($field);
    $field = new PivotSumField("leads");
    $pivot->AddDataField($field);
    $field = new PivotField("category");
    $field->Expand = true;
    $pivot->AddRowField($field);
    $field = new PivotField("type");
    $field->Expand = true;
    $pivot->AddRowField($field);
    $field = new PivotField("campaign");
    $pivot->AddRowField($field);
    $field = new PivotField("franchise");
    $field->Expand = true;
    $pivot->AddColumnField($field);
    $field = new PivotField("date");
    $pivot->AddColumnField($field);
    $pivot->Process();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>KoolPivotTable</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    </head>
    <body>
        <form id="form1" method="post">
        	<?php echo $koolajax->Render();?>
        	<div style="padding-top:10px;">
		        <?php echo $pivot->Render();?>
            </div>
        </form>
    </body>
</html>
Posted Jan 4, 2016 , edited Jan 7, 2016 Kool
Kelly
Hi Kelly,
You would have to modify the source code of koolpivottable.php a bit. Please open the file and looking for "function RenderHeaderTotal" inside "class PivotSumField extends PivotField". Then in the function body which looks like:
function RenderHeaderTotal(...) {
      return <an expression>;
    }

please change the return command to like:
function RenderHeaderTotal(...) {
      return <an expression> . $this->FieldName ;
    }

That would add the field name to the last of the header. Please let us know if there's any issue. Thanks!
--
Best regards,
David Winterburn
Support and Development Team
KOOLPHP .Inc - www.koolphp.net
Posted Jan 13, 2016 , edited Jan 13, 2016 Kool