KoolPivotTable
|
| | |
KoolPivotTable - Powerful PHP Pivot TableFullVersion 3.8.0.0 released on 25/11/2016
Display - KoolPivotTable Styles
Description & Sample code
KoolPivotTable starts supporting right-to-left languages. To enable this feature, assign the css class "rtl" or "text-right" to multiple section of the grid: Field - Column header - Row header - Data cell - Filter panel
<?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
$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();?>
<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>
| | |
|