This topic is locked

How to suppress the display of any given column listed in the Columns_Control item

3/9/2022 5:13:05 PM
PHPRunner General questions
P
psiconsultants author

I'm trying to customize which specific columns are displayed in a listing page for various user groups, and have that synchronized with the Columns_Control option that users are also allowed to hide/unhide their columns.

I am able to hide columns by putting the following code in the "Before display" event:

if (Security::getUserGroup() == "Approvers") {
$pageObject->hideField("cost_code");
$pageObject->hideField("cost_index");
$pageObject->hideField("cost_long");
}

This works just fine, however when the user clicks on the Columns_Control button, they still see the toggles for those specific fields. How can I remove just those items, and leave everything else in place?

I've tried this:
$pageObject->hideItem("columns_control", "$recordid");
but it hides the whole control, not any items within the control.

I've also tried this:
$pageObject->hideItem("columns_control", "cost_index");
but it has no affect at all.

Thanks in advance. I'm a newbie at coding so hopefully I'm just missing something obvious.

Thanks!

mbintex 3/10/2022

As a workaround you could do different list pages for your different user groups - guess that would be more intuitive for yourself instead of all this hiding and show stuff and you have a solution for the show/hide items menu.

Your navigation would have to handle the user groups and which list page to show though.

Sergey Kornilov admin 3/10/2022

You need to make sure that Security::getUserGroup() returns "Approvers" as a group name. Probably for starters you need to remove the condition and just hide the field without checking for the group name.

P
psiconsultants author 3/10/2022

To clarify, the code I described above works just fine for hiding the columns on the table. It hides the specifics fields that I want hidden for the "Approvers" group.

My issue is that the Columns Control item that allows the "Approvers" group users to still see those column names (cost_code, cost_index, cost_long) in the Columns Control object. It is very misleading because checking or unchecking them does nothing, but the column is hidden. I want to remove those values from the Columns Control object. See screenshot example.

img alt

I know how to hide the Columns Control object altogether, but I don't want to do that.