Get KoolPHP UI with 30% OFF!

Column Fields with custom value map can be reordered even if field's property "AllowReorder" is set to false

Martin
If I use Column fields with a custom value map then the field can be reordered regardless of the field->AllowReorder value. If no value map is used then the reordering works as expected. Is this a bug? This is a working example using your sample db table "payments". Search the comment lines beginning with "uncomment" and toggle the comments accordingly to test both Versions of column fields:
<html><body>
<?php
/* Possible Bug?
 *
 *  - Column Field with a value map are reorderable even if the AllowReorder = false. Column Fields
 *    with no custom value mapping are fine
 *    RESOLUTION: bug in Pivot table, report!
*/
$KoolControlsFolder = "../classes/KoolControls";
require_once($KoolControlsFolder."/KoolAjax/koolajax.php");
$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax";
require $KoolControlsFolder."/KoolPivotTable/koolpivottable.php";
class MyValueMap implements PivotIValueMap
{
	function map($_value)
	{
		return array("YEAR" => substr($_value, 0, 4) );
	}
	function getMapFields()
	{
		return array("YEAR");
	}
}
/// MAIN
$db = mysql_connect("localhost", "root", "root");
mysql_select_db("kooltest");
$ds = new MySQLPivotDataSource($db);
$ds->select("customerNumber, paymentDate, amount")->from("payments");
$pivot = new KoolPivotTable("pivot");
$pivot->scriptFolder = $KoolControlsFolder."/KoolPivotTable";
$pivot->styleFolder = "office2007";
$pivot->DataSource = $ds;
$pivot->AjaxEnabled = true;
$pivot->Width = "1400px";
$pivot->HorizontalScrolling = true;
$pivot->Height = "800px";
$pivot->HorizontalScrolling = true;
$pivot->AllowFiltering = true;
$pivot->AllowSorting = true;
$pivot->AllowSortingData = true;
$pivot->AllowReorder = true;
$pivot->AllowCaching = true;
$pivot->ShowGrandColumn = false;
$pivot->ShowStatus = true;
$pivot->Appearance->RowHeaderMinWidth = "200px";
//Use the Prev and Next Numneric Pager
$pivot->Pager = new PivotPrevNextAndNumericPager();
$pivot->Pager->PageSize = 20;
//DATA FIELD
$field = new PivotSumField("amount");
$field->Text = "AMOUNT";
$field->FormatString = "{n}";
$field->AllowReorder = false;
$field->AllowFiltering = false;
$pivot->AddDataField($field);
$pivot->SetDataFieldForSorting($field);
// COLUMN FIELD
$field = new PivotField("paymentDate");
// uncomment the next line to see the version with the value map
// RESULT: reordering is always allowed -> BUG
$field->setValueMap(new MyValueMap());
// uncomment the next line to see the version without the value map
// RESULT: reordering corresponds to AllowReorder settings
//$field->Text = "YEAR";
$field->AllowReorder = false;
$pivot->AddColumnField($field);
// ROW FIELD
$field = new PivotField("customerNumber");
$field->Text = "CUSTOMER CODE";
$field->AllowReorder = false;
$pivot->AddRowField($field);
$pivot->Process();
?>
<form id="form1" method="post">
	<?php echo $koolajax->Render();?>
	
	<div style="padding-top:10px;">
		<?php echo $pivot->Render();?>
	</div>
</form>
</body></html>

When you switch-on the value map you may also see another problem - the grid for column headers and their values is not vertically aligned. I'll Report it in another Topic.
Posted Oct 2, 2015 , edited Oct 2, 2015 Kool -