KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Pivot table fixed header #2936

Open Lalitha opened this topic on on Jan 11, 2023 - 2 comments

Lalitha commented on Jan 11, 2023

need pivot table header to be fixed . 
![](https://cdn.koolreport.com/assets/images/editor/c5/image63bea0a5946b8.png)

Lalitha commented on Jan 11, 2023

Pivottable::create(array(

"dataStore" => isset($this->params["code"]) ? $this->dataStore("sales") : [],
"serverPaging" => true,
//"template" => "Pivottable-Bun",
// "hideSubtotalRow" => true,

      "FixedHeader" => true,
"hideSubtotalColumn" => true,
"showDataHeaders" => true,
"rowDimension" => "row",
"measures" => array(
    "SALEVOL - sum",
    "SALEVAL - sum", 
    "PLNVOL - sum",
    "PLNVAL - sum",
    "SALEVOLC - sum",
    "SALEVALC - sum",
    "PDBVOL - sum",
    "PDBVAL - sum",
),
// "rowSort" => array(
//     "TOTUSERSCH - sum" => "desc",
//     "USERVOL - sum" => "desc",
// ),
// "columnSort" => array(
//     'TOTUSERSCH' => function ($a, $b) {
//         return (int) $a < (int) $b;
//     },
// ),
"rowCollapseLevels" => array(0,1,2),
"totalName" => "All",
'waitingFields' => array(
    'SALEVOL - sum' => 'data', 
    'SALEVAL - sum' => 'data', 
    'PLNVOL - sum' => 'data',
    'PLNVAL - sum' => 'data',
    'SALEVOLC - sum' => 'data',
    'SALEVALC - sum' => 'data',
    'PDBVOL - sum' => 'data',
    'PDBVAL - sum' => 'data',
             
    'SUBJECTNM' => 'label', 
    'SERIESNM' => 'label', 
    
),
"width" => "100%",
'paging' => array(
    'size' => 20
),
// "nameMap" => array(
//     "TOTUSERSCH - sum" => "Total User School",
//     "USERVOL - sum" => "Total User Volume",
// ),  

// "map" => array(
//     "rowField" => function($rowField, $fieldInfo) {
//         $v = $rowField;
//         if ($v === "BOARD")
//             $v = "BOARD";
//         else if ($v === "SUBJECTNM")
//             $v = "SUBJECT";
//         else if ($v === "SERIESNM")
//             $v = "SERIES";
//         return $v;
//     },
//     "columnField" => function($colField, $fieldInfo) {
//         $v = $colField;
//         if ($v === "TOTUSERSCH - sum")
//             $v = "USER SCHOOL";
//         else if ($v === "USERVOL - sum")
//             $v = 'USER VOLUME';
//         return $v;
//     },
// ),
'headerMap' => function($v, $f) {
    switch ($v) {
        case "SALEVOL - sum": return "2021-22 Net Volume Sale";
        case "SALEVAL - sum": return "2021-22 Net Value Sale";
        case "PLNVOL - sum": return "2022-23 Planned Volume";
        case "PLNVAL - sum": return "2022-23 Planned Value";
        case "SALEVOLC - sum": return "2022-23 Net Volume Sale";
        case "SALEVALC - sum": return "2022-23 Net Value Sale";
        case "PDBVOL - sum": return "2022-23 PDB Volume";
        case "PDBVAL - sum": return "2022-23 PDB Value";
       
        case 'SCNAME': return 'SCHOOL NAME';
        case 'SUBJECTNM': return 'SUBJECT NAME';
        case 'SERIESNM': return 'SERIES NAME';
    }
    $r = $v;
    // if ($f === 'orderYear')
    //     $r = 'Year ' . $v;
    // $map = array(
    //     '1' => 'January',
    //     '2' => 'February',
    //     '3' => 'March',
    //     '4' => 'April',
    //     '5' => 'May',
    //     '6' => 'June',
    //     '7' => 'July',
    //     '8' => 'August',
    //     '9' => 'September',
    //     '10' => 'October',
    //     '11' => 'November',
    //     '12' => 'December',
    // );
    // if ($f === 'orderMonth')
    //     $r = $map[$v];
    return $r;
},
'cssClass' => array(
    "table" => "table table-bordered table-striped table-hover cssText is-datatable krpmDataFieldZone krpmFieldDropContainer krpmRowFieldZone krpmFieldDropContainer krpmDataFieldZone krpmRowHeaderZoneDiv",
    //"table" => "table table-bordered table-striped table-hover pivot-data-field-content pivot-data-field-zone pivot-row-header-total .pivot-row-header-text pivot-column-header-total .pivot-column-header-text pivot-column-header-grand-total",        

    'waitingField' => function($field, $fieldInfo) {
        return "cell-class-name";
    },
    'dataField' => function($field, $fieldInfo) {
        return "cell-class-name1";
    },
    'columnField' => function($field, $fieldInfo) {
        return "cell-class-name1";
    },
    'rowField' => function($field, $fieldInfo) {
        return "cell-class-name1";
    },
    'columnHeader' => function($header, $headerInfo) {
        return "cell-class-name1";
    },
    'rowHeader' => function($header, $headerInfo) {
        return "cell-class-name";
    },
    'dataCell' => function($value, $cellInfo) {
        return "cell-class-name1";
    },
),
'partialProcessing'=>true,

));

Sebastian Morales commented on Jan 12, 2023

Sorry, PivotTable / PivotMatrix doesn not have fixed headers yet.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Pivot