Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Customize & Extend
Answered

Entity List View Selector - Would like to hide a view with javascript

(0) ShareShare
ReportReport
Posted on by 5

Hello,

 

I have an entity list which has 3 views in the view selector. I would like to hide views based on the user's web roles with javascript. I am able to capture the web roles from a liquid tag, but cannot figure out how to hide an individual view. The sample code i get with Copilot is:

 

$(document).ready(function() {
// Wait for the entity list to load
  $(".entitylist").on("loaded", function() {
    var roles = '{{ user.roles }}'; // Get the user's roles
    console.log(roles);
    // Find the dropdown menu for views
    var viewDropdown = $(this).find(".view-select");
 
    // Find the option for the view you want to hide and hide it
    viewDropdown.find('option[value="Portal Teachers - System-Wide"]').hide();
  });
});
 
The view does not hide. I would like to do this without creating a web template which is a suggestion in another post. Is this possible?
Categories:
  • Jazzy4321 Profile Picture
    5 on at
    Re: Entity List View Selector - Would like to hide a view with javascript

    That worked perfectly as is. Thanks so much!

  • Verified answer
    Fubar Profile Picture
    7,964 Super User 2025 Season 1 on at
    Re: Entity List View Selector - Would like to hide a view with javascript

    The bit that does the hiding in your code is not correct.  The following can probably be refined a bit, AND you will also have to handle the case where the view is the currently selected view also. 

    Not using the variable at all, something similar to 

     

     

    $("#filterDropdownId ul.dropdown-menu li a[aria-label='Portal Teachers - System-Wide']").parent().hide();

     

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 69 Super User 2025 Season 1

#2
oliver.rodrigues Profile Picture

oliver.rodrigues 49 Most Valuable Professional

#3
Jon Unzueta Profile Picture

Jon Unzueta 43

Featured topics