KoolReport's Forum

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

Freezing the first column in drill down with a datatables #3089

Closed Lalitha opened this topic on on Jul 5, 2023 - 1 comments

Lalitha commented on Jul 5, 2023

Freezing happening but first column data is repeating twice

<?php
    require_once(dirname(__FILE__) . "/../../../layout/header.php");
    use \koolreport\drilldown\DrillDown;
  //  use \koolreport\processes\CopyColumn;
    use \koolreport\processes\DateTimeFormat;
    use \koolreport\widgets\google\ColumnChart;
    use \koolreport\widgets\koolphp\Table;
    use \koolreport\inputs\Select;
use \koolreport\datagrid\DataTables;
?>
<BR/>
<div class="report-content">
     
    <?php

        DrillDown::create(array(
        "name"=>"saleDrillDown",
        "title"=>"Analyze Office & Executive Wise Schools Planning",
        "levels"=>array(
            array(
                "title"=>"All Zones",
                "content"=>function($params,$scope)
                {
                    DataTables::create(array(
                        "name" => "ZoneTable",
                        "id" => "zonetable",
                        "dataSource"=>(
                            $this->src("automaker")->query("
                            SELECT upper(zone) zone,sum(isnull(USERSCH,0)) USERSCH,sum(isnull(LOSTSCH,0)) LOSTSCH,sum(isnull(USERSCHPLAN,0)) USERSCHPLAN,sum(isnull(USERSCHPLANVISIT,0)) USERSCHPLANVISIT,
                            sum(isnull(USERSCHREMOVE,0)) USERSCHREMOVE,sum(isnull(USERSCHREMVISIT,0)) USERSCHREMVISIT,sum(isnull(LOSTSCHPLAN,0)) LOSTSCHPLAN,sum(isnull(LOSTSCHPLANVISIT,0)) LOSTSCHPLANVISIT,
                            sum(isnull(LOSTSCHREMOVE,0)) LOSTSCHREMOVE,sum(isnull(LOSTSCHREMVISIT,0)) LOSTSCHREMVISIT, sum(isnull(NEWSCHPLAN,0)) NEWSCHPLAN,sum(isnull(NEWSCHPLANVISIT,0)) NEWSCHPLANVISIT,
                            sum(isnull(UNPLANSCHVISIT,0)) UNPLANSCHVISIT,(sum(isnull(USERSCHPLAN,0))+sum(isnull(LOSTSCHPLAN,0)) + sum(isnull(NEWSCHPLAN,0))) TOTALCOV,
                            (sum(isnull(USERSCHREMOVE,0))+sum(isnull(LOSTSCHREMOVE,0))) TOTALREMOVE,
                            (sum(isnull(USERSCHPLANVISIT,0))+sum(isnull(USERSCHREMVISIT,0))+sum(isnull(LOSTSCHPLANVISIT,0))+sum(isnull(LOSTSCHREMVISIT,0))+sum(isnull(NEWSCHPLANVISIT,0))+sum(isnull(UNPLANSCHVISIT,0))) TOTALSCHVISIT,
                            ROUND(isnull((sum(USERSCHPLANVISIT)*100)/NULLIF(sum(USERSCHPLAN),0),0),2) USERSCHPLANVISITPER,ROUND(isnull((sum(LOSTSCHPLANVISIT)*100)/NULLIF(sum(LOSTSCHPLAN),0),0),2) LOSTSCHPLANVISITPER,
                            ROUND(isnull((sum(NEWSCHPLANVISIT)*100)/NULLIF(sum(NEWSCHPLAN),0),0),2) NEWSCHPLANVISITPER
                            FROM  PLANOVERVIEW where EXECCODE IN (" . $_SESSION['subordinates'] . ") and year='2022-2023'
                            GROUP BY ZONE ORDER BY (sum(isnull(USERSCHPLAN,0))+sum(isnull(LOSTSCHPLAN,0)) + sum(isnull(NEWSCHPLAN,0))) DESC
                            ")
                        ),  
                        "plugins" => ["fixedColumns"],
                        "options" => array(
                            "scrollY" => "500px",
                            "scrollX" => true,
                            "scrollCollapse" => true,
                            "select" => array(
                                "style" => "single"
                            ),
                            "ordering" => false,
                            "fixedColumns" => array(
                                "leftColumns" => 1,
                                "heightMatch" => "auto" // Add this line
                            ),
                            "fixedHeader" => true
                        ),
                        "responsive"=>true,
                        "showFooter"=>true,
                        "title"=>"Zone Wise Planning",
                        "columns"=>array(
                            "zone"=>array(
                                "type"=>"string",
                                "label"=>"ZONE",     ),
                                "USERSCH"=>array(
                                "type"=>"number",
                                "label"=>"Total User School 2022-23",  ),                      					
	                        "USERSCHPLAN"=>array(
                                "type"=>"number",
                                "label"=>"User Schools Planned",   ),
                            "USERSCHPLANVISIT"=>array(
                                "type"=>"number",
                                "label"=>"Planned User Schools Visited",   ),
                            "USERSCHREMOVE"=>array(
                                "type"=>"number",
                                "label"=>"User Schools Removed", ),
                            "USERSCHREMVISIT"=>array(
                                "type"=>"number",
                                "label"=>"Removed User Schools Visited",),
                            "USERSCHPLANVISITPER" => array(
                                "label" => "% Planned User Schools Visited",
                                "type" => "num-fmt",
                                "type" => "number",
                                "decimals" => 2,
                                "decimalPoint" => ".",    ),
                            "LOSTSCH"=>array(
                                "type"=>"number",
                                "label"=>"Total Lost School 2022-23",    ),	
                            "LOSTSCHPLAN"=>array(
                                "type"=>"number",
                                "label"=>"Lost Schools Planned",    ),
                            "LOSTSCHPLANVISIT"=>array(
                                "type"=>"number",
                                "label"=>"Planned Lost Schools Visited",),
                            "LOSTSCHREMOVE"=>array(
                                "type"=>"number",
                                "label"=>"Lost Schools Removed",),
                            "LOSTSCHREMVISIT"=>array(
                                "type"=>"number",
                                "label"=>"Removed Lost Schools Visited",  ),
                            "LOSTSCHPLANVISITPER" => array(
                                "label" => "% Planned Lost Schools Visited",
                                "type" => "num-fmt",
                                "type" => "number",
                                "decimals" => 2,
                                "decimalPoint" => ".",        ),
                            "NEWSCHPLAN"=>array(
                                "type"=>"number",
                                "label"=>"Non-User Schools Planned",       ),
                            "NEWSCHPLANVISIT"=>array(
                                "type"=>"number",
                                "label"=>"Planned Non-User Schools Visited",   ),
                            "NEWSCHPLANVISITPER" => array(
                                "label" => "% Planned Non-User Schools Visited",
                                "type" => "num-fmt",
                                "type" => "number",  ),
                            "UNPLANSCHVISIT"=>array(
                                "type"=>"number",
                                "label"=>"Un-Planned Schools Visited",   
                            ),
                            "TOTALCOV"=>array(
                                "type"=>"number",
                                "label"=>"Total School Planned", ),
                            "TOTALREMOVE"=>array(
                                "type"=>"number",
                                "label"=>"Total School Removed",),
                            "TOTALSCHVISIT"=>array(
                                "type"=>"number",
                                "label"=>"Total School Visited",)
                        ),
                        "cssClass"=>array(
                            "table"=>"table table-hover ",
                            "th"=>"cssHeader",
                            "tr"=>"cssItem",
                            "tf"=>"cssIFooter",
                            "td"=>function($row,$colName)
                            {
                                if ($colName=="zone")
                                {
                                    return "cssTd";
                                }
                                else if($colName=="USERSCHPLAN" or $colName=="USERSCHREMOVE" or $colName=="NEWSCHPLAN"){
                                    return "cssTdr";
                                }
                                else if ($colName=="USERSCH" or $colName=="LOSTSCH" or $colName=="LOSTSCHPLAN" or $colName=="LOSTSCHREMOVE" or $colName=="TOTALCOV" or $colName=="TOTALREMOVE" )
                                {
                                    return "cssTdw";
                                }
                                else
                                {
                                    return "text-right";
                                }
                            },
                        ),
                        "cssClass"=>array(
                            "table"=>"table table-hover",
                            "th"=>"cssHeader",
                            "tr"=>"cssItem",
                            "tf"=>"cssIFooter",
                            "td"=>function($row,$colName)
                            {
                                if ($colName=="zone")
                                {
                                    return "cssTd";
                                }
                                else if($colName=="USERSCHPLAN" or $colName=="USERSCHREMOVE" or $colName=="NEWSCHPLAN"){
                                    return "cssTdr";
                                }
                                else if ($colName=="USERSCH" or $colName=="LOSTSCH" or $colName=="LOSTSCHPLAN" or $colName=="LOSTSCHREMOVE" or $colName=="TOTALCOV" or $colName=="TOTALREMOVE" )
                                {
                                    return "cssTdw";
                                }
                                else
                                {
                                    return "text-right";
                                }
                            },
                        ),
                             "clientEvents"=>array(
                            "select"=>"function(e,dt,type,indexes){
                                var data = dt.rows(indexes).data()[0];
                                console.log(data);
                                var dname=data[0];
                                console.log(dname);
                                saleDrillDown.next({zone:dname});
                            }",
                        )     
                    ));
                }
            ),
       
        ),
    ));[](
![
![](https://cdn.koolreport.com/assets/images/editor/c5/image64a51b70429a7.png)](https://cdn.koolreport.com/assets/images/editor/c5/image64a51b692e65c.png))

    ?>
</div>

<?php
require_once(dirname(__FILE__) . "/../../../layout/footer.php");
?>
Lalitha commented on Jul 10, 2023

I have found the solution with style changes

table.dataTable {
clear: both;
margin-top: -7px!important;
}
.DTFC_LeftHeadWrapper{
    background-color:whitesmoke !important;
}
.DTFC_LeftFootWrapper{
    background-color:whitesmoke !important;
}
.DTFC_LeftBodyLiner{
    background-color:whitesmoke !important;
}

"plugins" => ["FixedHeader","fixedColumns"],

                    "options" => array(
                        "colReorder" => true,
                        "scrollY" => "500px",
                        "scrollX" => true,
                        "scrollCollapse" => true,
                        "fixedHeader"=>true,
                        "fixedColumns" => array(
                      "leftColumns" => 1
                         ),
                       // "select" => true,
                       "select" => array(
                        "style" => "single" 
                    ),
                       "ordering" => false,
                    ),

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
None yet

None