Get KoolPHP UI with 30% OFF!

Pivot table does not render with CSS colors

Carlos Eduardo
<?php 
    /*
     * Please put this file in the same folder with KoolControls folder
     * or you may modify path of require and scriptFolder to refer correctly
     * to koolpivottable.php and its folder.
     */
    //require "kphp/KoolControls/KoolPivotTable/koolpivottable.php";
    require "kphp/KoolControls/KoolAjax/koolajax.php";
	$koolajax->scriptFolder = "kphp/KoolControls/KoolAjax";
 
  require "kphp/KoolControls/KoolPivotTable/koolpivottable.php";
  
  
  $serverName = "WIN-OLOEBBM0T2N\INTELLITI"; 
  $uid = "sa";   
  $pwd = "Guardian*01";  
  $databaseName = "IOCP"; 
$connectionInfo = array( "UID"=>$uid,                            
                         "PWD"=>$pwd,                            
                         "Database"=>$databaseName); 
	
   $dbcon = sqlsrv_connect( $serverName, $connectionInfo);  	
   
    //$ds = new SQLSVRPivotDataSource($dbcon); 
	$ds = new SQLSRVPivotDataSource($dbcon);
	
	if(isset($_POST["style_select"]))
	{
		$_SESSION["style_select"] = $_POST["style_select"];
	}
	else
	{
		if (!$koolajax->isCallback)
		{
			//Page Init: show default style
			$_SESSION["style_select"] = "office2007";
		}
	}
	
	$ds->select("ANOFISCAL, ANOMESFISCALINT, N3, CMV_PLANEJADO, MARKDOWN, CMV_REALIZADO, ESTOQUE_FINAL_CUSTO_PLANEJADO, ESTOQUE_DISPONIVEL_CUSTO, ESTOQUE_RECEBIMENTOS_CUSTO, ESTOQUE_TOTAL_DISPO_CUSTO, OTB_PROX_PERIODO, PEDIDOS_CONSUMO, OTB_DISPO      ")
       ->from("otb_inseason");
    //   ->selectCommand("SELECT * FROM otb_inseason");
    $pivot = new KoolPivotTable("pivot");
    $pivot->scriptFolder = "KoolControls/KoolPivotTable";
    $pivot->DataSource = $ds;
//Turn on ajax features.
    $pivot->AjaxEnabled = true;
	
	$pivot->Width = "800px";
	$pivot->HorizontalScrolling = true;
 
	//Set the Height of pivot and use Vertical Scrolling
	$pivot->Height = "400px";
	$pivot->VerticalScrolling = true;
 
	//Allow filtering
	$pivot->AllowFiltering = true;
	//Allow sorting
	$pivot->AllowSorting = true;
	//Allow reordering
	$pivot->AllowReorder = true;
 
 
	//Make the RowHeader wider.
	$pivot->Appearance->RowHeaderMinWidth = "250px";
 
	//Use the Prev and Next Numneric Pager
	$pivot->Pager = new PivotPrevNextAndNumericPager();
	$pivot->Pager->PageSize = 20;
 
 
    //$pivot->Pager = PivotPrevNextAndNumericPager();
    $pivot->AllowCaching = true;
    $pivot->ExportSettings->IgnorePaging = true;
    $pivot->ExportSettings->config(array(
            "fileName"=>"CompassExport",));
 
    $field = new PivotSumField("CMV_PLANEJADO");
    $field->Text = "CMV Planejado";
    $field->DecimalNumber = 2;
    $field->DecimalPoint = ",";
    $field->ThousandSeperate = ".";
    $field->FormatString = "R$ {n}";
    $pivot->AddDataField($field);
 
    $field = new PivotSumField("MARKDOWN");
    $field->Text = "Markdown";
    $field->DecimalNumber = 2;
    $field->DecimalPoint = ",";
    $field->ThousandSeperate = ".";
    $field->FormatString = "R$ {n}";
    $pivot->AddDataField($field);
 
    $field = new PivotField("N3");
    $field->Text = "Nível 03 EM";
    $pivot->AddRowField($field);
 
    $field = new PivotField("ANOMESFISCALINT");
    $field->Text = "Mês";
    $field->AllowReorder = true;
    $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>
        <?php echo $pivot->Render(); ?>
    </body>
</html>
Posted Feb 24, 2019 Kool