KoolReport's Forum

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

How to set up hyperlinks within the pivot table? #2361

Closed Rudy Tantra opened this topic on on Sep 29, 2021 - 5 comments

Rudy Tantra commented on Sep 29, 2021

What is in the green area shows the number of people from the male/female category -> rank.

How can I hyperlink each total (so that after clicking on the total, the window with this total amount of specific data opens to another page with rank values ​​as data to be sent to that other page)?

Should I add a hyperlink like this:

function setup()
        {   
            $node = $this->src('apiarray')->load($this->data);
            $node->pipe(new ColumnMeta(array(
                'total'=>array(
                    'type' => 'number'
                ),
            )))
            
            ->pipe(new Pivot(array(
                'dimensions'=>array(
                    'row'=>'Jenis_Kelamin,Golongan_Nama,Pangkat_Nama',
                ),
                'aggregates'=>array(
                    'sum'=>'<button type="button" class="btn btn-link-primary" onclick="to_personel(<?=Util::get($dataRow, $df, $emptyValue);?>, `" + row.Personel_Id + "`)"> A </button>, T, Ctr',
                    // A for total Aktif Organisasi, T for total Non Aktif Organisasi, Ctr for Jumlah
                )
            )))	
            ->pipe($this->dataStore('Rekap'));
            
          
        }

in the 'aggregates'=>array(

                'sum'=>'<button type="button" class="btn btn-link-primary" onclick="to_personel(<?=Util::get($dataRow, $df, $emptyValue);?>, ` " + row.Personel_Id + "`)"> A </button>, T, Ctr',
                // A for total Organizational Active, T for Total Organizational Inactivity, Ctr for Total
            )

but the output is (-) like this:

how is the correct way to create hyperlinks in the total pivot table?

Sebastian Morales commented on Sep 29, 2021

There's the "map" property of PivotTable which you could use to create links/buttons like this:

//MyReport.view.php
PivotTable::create(array(
    ...
    "map" => array(
        "dataCell" =>  => function ($value, $cellInfo) {
            $link = "<a href='item.php?name=$value'>"; //create links, buttons here
            return $link;
        }
    ),
));

Let us know if this is what you want. Tks,

Rudy Tantra commented on Sep 29, 2021

Thanks a lot, Sebastian Morales, this worked.

But I have another problem, which is like this:

if the link uses "<a href='item.php?name=$dataField'>$dataField</a>" works.

But here I want to use "<button type='button' class='btn btn-link-primary btn-rekap-pangkat' onclick='to_personel(`" + $dataField + "`, `" + $dataField + "`)'> " + $dataField + " </button>", and when I try, it doesn't work.

Can you help me again?, Thanks in advance.

Sebastian Morales commented on Sep 29, 2021

Pls right mouse click the mapped data cells and choose Inspect element, then find out what html values the cells are and how they are not correct. Rgds,

Rudy Tantra commented on Sep 30, 2021

when I look through the inspect element, there is no error, when I use "<a href='item.php?name=$dataField'>$dataField</a>" the value appears with the position wrapped by the <a> link, but when I use "<button type='button' class='btn btn-link-primary' onclick='to_personel(`" + $dataField + "`, `" + $dataField + " `) '> " + $dataField + " </button>" the value is out but there is no <button> link. How can I use the <button> link?

Thanks.

Rudy Tantra commented on Sep 30, 2021

the error was found and fixed, thanks for the help, Sebastian.

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