KoolPivotTable
|
| | |
KoolPivotTable - Powerful PHP Pivot TableFullVersion 3.8.0.0 released on 25/11/2016
First Look - KoolPivotTable Styles
Description & Sample code
KoolPivotTable is a simple yet powerful business ananysis tool. The strong point is the ability to let user create data view by their own with the combination of fields in row and column.
KoolPivotTable is flexible in changing style. It also support the data filtering and sorting. Also the scrolling and paging features of pivot table
gives users a convenient way to navigate through data.
<?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";
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 = 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 = $_SESSION["style_select"];
$pivot->DataSource = $ds;
//Turn on ajax features.
$pivot->AjaxEnabled = true;
//Set the Width of pivot and use horizontal scrolling
$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;
//Turn on caching to help pivot working faster.
$pivot->AllowCaching = true;
$pivot->CssClasses = array(
'data cell' => 'text-right',
// 'field' => 'rtl',
// 'column header' => 'text-right',
// 'row header' => 'rtl',
// 'filter panel' => 'rtl'
);
//Data Field
$field = new PivotSumField("dollar_sales");
$field->Text = "Dollar Sales";
$field->FormatString = "\${n}";
$field->AllowReorder = false;
$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();?>
Select style:
<select id="style_select" name="style_select" onchange="submit();">
<option value="default" <?php if ($_SESSION["style_select"]=="default") echo "selected" ?> >Default</option>
<option value="office2007" <?php if ($_SESSION["style_select"]=="office2007") echo "selected" ?> >Office2007</option>
</select>
<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>
| | |
|