Hide Menu item in Page Rules

Currently it is possible to hide Views when criteria doesn't match, but hiding one single item on a Menu view would be appreciative.

Example:

If User <>"Administrator":
Add Worker | Add Inspection

If User = "Administrator":
Add Worker | Add Inspection | Add Service

Having to create a separate Menu View for the one item I need to hide shouldn't be necessary.

The developer console in your browser is your friend here Loic (I use chrome) and I reckon it'd report a missing token.  The second render view event needs closing with another bracket and semi-colon I think like this:

$(document).on('knack-view-render.view_955', function(event, view, data) 
    if ($("#view_955-field_1536").val() != "0") {
         $(document).on('knack-view-render.view_957', function(event, view, data) {
              $("#view_957 > div > a > span:contains('Group')").parent().hide(); 
}); //<- here
}
});

Keep in mind I'm no expert by any stretch but Knack has helped me learn Javascript and CSS having moved apps over from MS Access (and VBA!).

 

Hi Brad, 

 

Thank for your reply. So I have tried to add the conditional test but it crashes my app (I am not a developer at all so it is not surprising). 

 

Here is my code

 

$(document).on('knack-view-render.view_955', function(event, view, data) 
       if ($("#view_955-field_1536").val() != "0") {
             $(document).on('knack-view-render.view_957', function(event, view, data) {
                  $("#view_957 > div > a > span:contains('Group')").parent().hide();
}
}
});

 

View 955 is a detail view containing the field used in the condition test. View 957 is the menu. I feel like the issue is that there is no 'else' but I have no idea how to write 'else do nothing'

Funny, I was just working on some code that included this - #view_841 is the menu view itself, and this hides the item with the text 'New Task'.  The code sits inside conditional tests.

$("#view_841 > div > a > span:contains('New Task')").parent().hide();

Hi Brad, 

Would mind sharing an example of how you coded this with js?

Thank you

Agreed, we currently do this in Javascript code but it's cumbersome.

+1

@Ally bumping for your consideration, because I was about to write a feature request, and realised I had written one 6 years ago! :laughing:
Thanks!

Hey Stephen, thanks for the bump! Going to have a chat to @Kara about this and make sure its on her radar.