Hello.

I'm looking for a example to hide a field on the filter panel in a special condition.
I've found something in this forum, but all for hiding a field on Add/Edit page.

What i need is to hide a field under the following condition:

When a User has signed on, i read his possible values for (eg.) FieldA from a table. FieldA is defined as "Show on Filter Panel" so the User can use it on the Filter Panel. But some User are only allowed for one value and it makes no sense to show FieldA on the Filter Panel.

I think it must be set in the "Javascript onload Event" but i have no idea how. In the "After successful login Event" i identify, how much values of FieldA a user can see and write it in a SESSION variable. When the content of the variable is 1 i want to hide FieldA on the Filter Panel.

Is this possible? 

Sure, this can be done.

1. BeforeDisplay event of the List page in question. Pass the value of logged user id to Javascript event:
$pageObject->setProxyValue("username", $_SESSION["UserID"]);


2. Javascript onload event of the same page. Hide FieldA filter is user is not an admin

if (proxy.username!='admin')
        $
("[class*=filter-FieldA-container]").hide();


Replace 'FieldA' with the actual field name. This is it. 

Post a Comment