KoolReport's Forum

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

Remove {{other}} column from report #2248

Open Ron opened this topic on on Aug 6, 2021 - 7 comments

Ron commented on Aug 6, 2021

Is it possible to remove the {{others}} column like in {{all}}

->pipe(new \koolreport\processes\RemoveColumn(array(
    '{{all}}'
)))
Sebastian Morales commented on Aug 6, 2021

Yes, you can remove it just like removing column "{{all}}". Rgds,

Ron commented on Aug 8, 2021

tried to do so and it does not work

->pipe(new \koolreport\processes\RemoveColumn(array(
    '{{all}}','{{others}}'
)))
Sebastian Morales commented on Aug 9, 2021

Pls post your code and screenshots of the problem. Tks,

Ron commented on Aug 9, 2021
$this->src("db")
        ->query('CALL getTeacherSchedule(:year, :teacher_id)')
        ->params(array(
            ':year' => $this->params['year'],
            ':teacher_id' => $this->params['teacher_id']
        ))
        ->saveTo($node1);

        foreach ($this->teachersList as $teacher) {
            $node1->pipe( new Filter( array (
                array("teacher_id", "=", $teacher['id']),
                "or",
                array("teacher_id","findInSet",$teacher['id']),
            )))
            ->pipe(new \koolreport\processes\Map(array(
                "{value}" => function($row) {
                    $row['class_name'] =
                        //$row['class_name'].'<br>'.
                        ( $this->params['show_class'] != null ? $row['class_name'] != '' ? $row['class_name'] : lang('tts.no_class') : null ).'<br>'.
                        ( $this->params['show_profession'] != null ? $row['profession_name'] : null ).'<br>'.
                        ( $this->params['show_room'] != null ? $row['room_name'] : null );
                    if ( $this->params['teacher_id'] != 0 ) {
                        $this->teachersList[0]['teacher_name'] = $row['teacher_name'];
                    }
                    return $row;
                },
            )))
            ->pipe(new \koolreport\processes\Map(array(
                "{end}" => function($count, $mapState) {
                    $emptyRows = [];
                    //$days = [1, 2, 3, 4, 5, 6]; //use day name if it's your case
                    foreach ($_SESSION['settings']->allowed_days as $key => $day) {
                        if ($day == true) {
                            foreach ($_SESSION['settings']->allowed_hours as $h_key => $hour) {
                                if ($hour == true) {
                                    $emptyRows[] = ['day' => $key, 'hour_num' => $h_key];
                                }
                            }
                        }
                    }
                    return $emptyRows;
                }
            )))
            ->pipe(new Cube(array(
                'row' => 'hour_num',
                'column' => 'day',
                'max' => 'class_name'
            )))
            ->pipe(new koolreport\processes\ColumnsSort(array(
                "{name}" => "asc", //or "desc" or function($colName1, $colName2) {...}
            )))
            ->pipe(new \koolreport\processes\Map(array(
                "{value}" => function($row) {
                    foreach ($row as $k => $v)
                        if ($v == null) $row[$k] = "";
                    return $row;
                }
            )))
            ->pipe(new \koolreport\processes\RemoveColumn(array(
                '{{all}}','{{others}}'
            )))
            ->pipe(new \koolreport\processes\Map(array(
                "{meta}" => function($meta) {
                    $colMetas = $meta["columns"];
                    foreach ($colMetas as $colKey => $colMeta) {
                        if (is_numeric($colKey)) {
                            $colMetas[$colKey]['label'] = lang("tts.day_$colKey"); //for columns '1', '2', etc
                            $colMetas[$colKey]['cssStyle'] = "width: 120px";
                        }
                        else {
                            $colMetas[$colKey]['label'] = lang("tts.$colKey"); //for column 'hour_num'
                            $colMetas[$colKey]['cssStyle'] = "width: 80px";
                        }
                    }
                    $meta["columns"] = $colMetas;
                    return $meta;
                }
            )))
            ->pipe($this->dataStore("DS_" . $teacher['id']));
Sebastian Morales commented on Aug 10, 2021

Pls post screenshots of the problem as well. Did the "{{others}}" column still appear after the RemoveColumn process? Rgds,

Ron commented on Aug 10, 2021

Yes it did. I had to solve the issue from the stored procedure side to eliminate any Null that i have in one of the (row, column, max) columns that I return. Before I did so I can assure you that even after using the code above using the RemoveColumn the column {{others}} still appears.

Sebastian Morales commented on Aug 11, 2021

We tested RemoveColumn for "{{others}}" column after Cube process and found that the column was remove like any column did normally. We suggest next time you only keep the Cube and RemoveColumn processes and remove all the other codes. Then check the datastore to see the result.

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