KoolPivotTable
|
| | |
KoolPivotTable - Powerful PHP Pivot TableFullVersion 3.8.0.0 released on 25/11/2016
Features - Scrolling Feature
Description & Sample code
You can turn on the horizontal scrolling by:
$pivot->Width = "800px"; //Set the width for pivot
$pivot->HorizontalScrolling = true; //Turn on horizontal scrolling.
And you can turn on the vertical scrolling by:
$pivot->Height = "400px"; //Set the height for pivot
$pivot->VerticalScrolling = true; //Turn on vertical scrolling.
<?php
/*
* This file is ready to run as standalone example. However, please do:
* 1. Add tags <html><head><body> to make a complete page
* 2. Change relative path in $KoolControlFolder variable to correctly point to KoolControls folder
*/
$KoolControlsFolder = "../../../../KoolControls";//Relative path to "KoolPHPSuite/KoolControls" folder
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax";
require $KoolControlsFolder."/KoolPivotTable/koolpivottable.php";
$ds = new MySQLiPivotDataSource($db_con);//This $db_con link has been created inside KoolPHPSuite/Resources/runexample.php
$ds ->select("customerName, productName, productLine, dollar_sales")
->from("customer_product_dollarsales");
$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
if(!$koolajax->isCallback)
{
$_SESSION["checkHorizontalScrolling"] = (isset($_POST["checkHorizontalScrolling"]))?true:false;
}
$pivot->Width = "800px";
$pivot->HorizontalScrolling = $_SESSION["checkHorizontalScrolling"];
//Set the Height of pivot and use Vertical Scrolling
if(!$koolajax->isCallback)
{
$_SESSION["checkVerticalScrolling"] = (isset($_POST["checkVerticalScrolling"]))?true:false;
}
$pivot->VerticalScrolling = $_SESSION["checkVerticalScrolling"];
if($pivot->VerticalScrolling)
{
$pivot->Height = "400px";
}
//Make the RowHeader wider.
$pivot->Appearance->RowHeaderMinWidth = "250px";
//Use the Prev and Next Numneric Pager
$pivot->Pager = new PivotPrevNextAndNumericPager();
$pivot->Pager->PageSize = 20;
//Turn on caching to help pivot working faster.
$pivot->AllowCaching = true;
//Data Field
$field = new PivotSumField("dollar_sales");
$field->Text = "Dollar Sales";
$field->FormatString = "\${n}";
$field->AllowReorder = false;//Turn off the reorder for data field
$pivot->AddDataField($field);
//Row Fields
$field = new PivotField("customerName");
$field->Text = "Customer";
$pivot->AddRowField($field);
//Column Fields
$field = new PivotField("productLine");
$field->Text = "Product Line";
$pivot->AddColumnField($field);
$field = new PivotField("productName");
$field->Text = "Product";
$pivot->AddColumnField($field);
//Process the pivot
$pivot->Process();
?>
<form id="form1" method="post">
<?php echo $koolajax->Render();?>
<div><input name="checkHorizontalScrolling" id="checkHorizontalScrolling" type="checkbox" <?php echo ($pivot->HorizontalScrolling)?"checked":""; ?> onchange="form1.submit()" /><label for="checkHorizontalScrolling">Horizontal Scrolling</label></div>
<div><input name="checkVerticalScrolling" id="checkVerticalScrolling" type="checkbox" <?php echo ($pivot->VerticalScrolling)?"checked":""; ?> onchange="form1.submit()" /><label for="checkVerticalScrolling">Vertical Scrolling</label></div>
<div style="padding-top:10px;">
<?php echo $pivot->Render();?>
</div>
<div style="margin-top:10px;"><i>* <u>Note</u>:</i>Generate your own pivot table with <a style="color:#B8305E;" target="_blank" href="http://codegen.koolphp.net/pivot_table/">Code Generator</a></div>
</form>
| | |
|