KoolReport's Forum

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

Hide columns in datagrid #2307

Open Sawan Ruparel opened this topic on on Aug 27, 2021 - 6 comments

Sawan Ruparel commented on Aug 27, 2021

Hello !!

I am using Datagrid's clientRowGroup option with laravel. I wanted to hide my column that is added in group.

For ex:-

"columns" => [
                "pharm_name" => [
                    "label" => 'Pharmacy Name'
                ],
],
"clientRowGroup" => [
                "pharm_name" => [],
                    "top" => "<td colspan='999'>{expandCollapseIcon} {pharm_name} </td>",
                ]
            ],

So in above case i dont want to display pharm_name like in below ss.

Note - I tried below links.

 1. https://www.koolreport.com/forum/topics/755
 2. https://www.koolreport.com/forum/topics/1449
 3. https://www.koolreport.com/forum/topics/1333

Sebastian Morales commented on Aug 28, 2021

How about:

"columns" => [
                "pharm_name" => [
                    "label" => 'Pharmacy Name',
                    "visible" => false,
                ],
],

Let us know the result. Tks,

Sawan Ruparel commented on Aug 28, 2021

Yes. That worked. Thank You!!

I have one more question -

For ex :- I wanted to display other columns details with pharm_name. I only can show the details whom i can sum or average. How to show other column details also there?

Sebastian Morales commented on Aug 30, 2021

Can you pls give a specific example which columns you group and which other column details you want to show in the group row?

Sawan Ruparel commented on Aug 30, 2021

I wanted to display pid in report like below.

For ex:-

"columns" => [

            "pharm_name" => [
                "label" => 'Pharmacy Name',
            ],

"pid" => [

                "label" => 'Pharmacy Number',
            ],

]

"clientRowGroup" => [

            "pharm_name" => [
                
                ],
                "top" => "<td colspan='999'>{expandCollapseIcon} {pharm_name} {pid}</td>",
            ]
        ],
Sebastian Morales commented on Aug 31, 2021

I see, assuming all rows with the same pharm_name also have the same pid pls try the following code and let me know the result:

"clientRowGroup" => [
    "pharm_name" => [
        "calculate" => [
            "lastPid" => [
                "field" => "pid",
                "aggregate" => "function(rows, group, aggFieldIndex) {
                    var initAgg = null;
                    return rows
                    .data()
                    .pluck(aggFieldIndex)
                    .reduce( function (agg, b) {
                        return b;
                    }, initAgg)}", // this aggregate returns the last row's pid
            ],
            ...
        ],
        "top" => "<td colspan="999">{expandCollapseIcon} {pharm_name} {lastPid}</td>",
    ],
    ...
] 
Sawan Ruparel commented on Sep 1, 2021

Ohh i see now. Thank you for your help. Appreciate it.

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

None