KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.

Hide Column and missing title #1714

Closed Carlo Di Michele opened this topic on on Nov 15 - 5 comments

Carlo Di Michele commented on Nov 15

Hello everybody this is my first post related to my first report so sorry for the dummy question.

This is my code in view.php:

<?php 
    use \koolreport\widgets\koolphp\Table;
?>

<div class="report-content">
    <div class="text-center">
        <h1>Elenco Prezzi</h1>
        <p class="lead">Elenco prezzi del lavoro Pippo</p>
    </div>

    <?php
    Table::create(array(
        "dataStore"=>$this->dataStore('elenco'),
        /*"columns"=>array("Tariffa","DescrizioneSint"),*/
		/*"excludedColumns"=>array("IDElenco", "ImportoSicurezza"),*/
		"options" => array(
            'columnDefs' => array(
                [
                    'visible' => false,
                    'targets' => [0, 1], // hide the 1st and 2nd columns
                ])),
        "cssClass"=>array("table"=>"table table-hover table-bordered")
    ));
    ?>
</div>

It shows everything with the following problems.

Problems:

  1. the div report Content is not shown. it shows "$this->dataStore('elenco')"
  2. I've tried to use an array: columns, excludedColumns and columnsDefs but it shows the whole columns in the table.

Error:

there is an Error in the debugger (not on the page): "ReferenceError: KoolReport is not defined" Line 654: KoolReport.widget.init.

I suppose that here there is the problem.

datastore: the csv structure (header and first record) is this (fields separated by ";"):

generated;IDElenco;ImportoSicurezza;PercentualeSicurezza;IDLavoro;NumOrdElenco;Tariffa;DescrizioneSint;DescrizioneCompl;UnitàMisura;PrezzoUnitario;PrezzoUnitarioLettere;PrezzoOfferta;Prezzo1;Prezzo2;Prezzo3;Prezzo4;Prezzo5;VoceFerro;LavoroEconomia;TotaleOperai;TotaleProvviste;Sommano;SpeseGenerali;UtileImpresa;SpeseGeneraliAP;UtileImpresaAP;PrezzoCalcolato;PrezzoApplicato;FlagInserimentoEP;Articolo;Categoria;PercentualeManodopera;ImportoManodopera
01/04/2020 11.32;1;0;0;1;1;A/1-1;Scavo di sbancamento compreso lo spianamento e la configurazione del f..... eseguito con mezzi meccanici.;Scavo di sbancamento compreso lo spianamento e la configurazione del fondo anche se a gradoni e l'eventuale profilatura di pareti, scarpate e simili, per pavimentazione stradale o simili, il taglio di alberi e cespugli, l'estirpazione di ceppaie, compreso il trasporto nell'ambito del cantiere secondo le indicazioni della Direzione Lavori. Scavo di sbancamento di materie di qualsiasi natura e consistenza, asciutte o bagnate, esclusa la roccia da mina ma compresi i trovanti rocciosi ed i relitti di muratura fino a mc 0.50 eseguito con mezzi meccanici.;mc;4,54;ottomilaottocento;4,54;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;100.00 A;SCAVI;0;0

Thanks for your help. Regards

KoolReport commented on Nov 16

From your report issue, I guess your report does not find its view so it show the debug view (which outputs all dataStores). Please make sure that you have 2 files: MyReport.php and MyReport.view.php. Inside the MyReport.php should have class MyReport extended from KoolReport. Here are sample.

Carlo Di Michele commented on Nov 16

Hello, this is MyReport.php file that contains the class extended:

<?php

// Require autoload.php from koolreport library require_once "../../koolreport/core/autoload.php";

//Define the class class ElencoPrezzi extends \koolreport\KoolReport {

use \koolreport\clients\Bootstrap;
protected function settings()
{
    //Define the "elenco" data source which is the elenco_prezzi.csv 
    return array(
        "dataSources"=>array(
            "elenco"=>array(
                "class"=>'\koolreport\datasources\CSVDataSource',
                "filePath"=>"elenco_prezzi.csv",
				"fieldSeparator"=>";"
            ),        
        )
    );
}

protected function setup()
{
    //Select the data source then pipe data through various process
    //until it reach the end which is the dataStore named "elenco".
    $this->src('elenco')->pipe($this->dataStore('elenco'));
}

}

Thanks for your support

Carlo Di Michele commented on Nov 16

Sebastian Morales commented on Nov 16

Carlo, by default without a view parameter KoolReport uses a report class name to guess its view file, in your case it would be ElencoPrezzi.view.php instead of Elenco_prezzi.view.php. Therefore, there're two solutions, either rename your report class, setup and view files to be the same or use a view parameter when you render the report in index.php:

    ...
    $report->run->render("Elenco_prezzi");

By the way, "columnDefs" option is only available with widget \koolreport\datagrid\DataTables of package Datagrid. For the core widget Table pls check its docs here:

https://www.koolreport.com/docs/koolphp/table/

Cheers,

Carlo Di Michele commented on Nov 16

Thaks a lot, it works :-)

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
solved

DataGrid