I have created a session variable. And have created a site column that sets a flag that corresponds to that session variable. I would like to hide/show list items across any list utilizing this site column. Is this something that is do-able? I have it working for a user control, but i just have to place an if-statement around the writer if the flag is set. I am unsure of how to do it for lists/libraries. I think i would have to somehow attach to a list-Item Pre-render and if the flag is set then either show/hide... but there is no such event receiver

  • What is your actual objective with this? It is a quite unusual approach so it would be nice to know your basic requirement Mar 25, 2014 at 18:47
  • I need to be able to show/hide list items, navigation links and in some cases html elements depending on if the user is on or off the network. I have a session variable that tells me on/off. I have been able to utilize this in custom user controls to show/hide things(among them is a custom Mega-Menu navigation), but when it comes to list items i am unsure how to i can achieve this. I am also open to "creative ideas", using jquery, or somehow getting the session variable or cookie that the user is on/off the network into the list (then i can just use views). Any help is much appreciated.
    – user5389
    Mar 26, 2014 at 0:36

1 Answer 1


I was able to get this working using jquery and a siteColumn. Below is what i did.

  1. I created a site column names 'Internal Only'
  2. Added this site Column to any list that may contain information i want hidden if the user was off the network.
  3. I use jquery to grab the session As i mentioned above i have a session variable and cookie. in my javascript i get that variables value
  4. If 'OFF' is the value i use the jquery below to hide the listitems.

     //get session variable value for network status
    var networkStatus = $.cookie("NetworkStatusCookie");   
    if (networkStatus == "OFF") {
    //find all the columns on the page with needed text
    $tables = $('table').each(function () {
        $th = $(this).find("th:contains('Internal Only')");
        //for each column found
        $th.each(function () {
            //find columns parent
            var colIndex = $th.index();
            //this -> column
            $th.parents("table").find("tr").each(function () {
                var $columnCell = $(this).children("td:eq(" + colIndex + ")");
                colText = $.trim($columnCell.text());
                $($columnCell).filter("td:contains('Yes')").parent('tr').css("display", "none");


  • Hiding stuff with JavaScript is generally not classified as security trimming. Any user with basic browser debugging skills can find your hidden elements Apr 4, 2014 at 19:02
  • Would you happen to have any suggestions on how to better meet the requirements? So far it is the only option i've been able to figure out... I guess i should also mention the information we re hiding is not extremely sensitive data, most are simply links that only work when on the network so its better to hide those so as to not have a bunch of broken links.
    – user5389
    Apr 5, 2014 at 1:59
  • For that type of information it sounds fine :) it was the words security trimming that frightened me a bit Apr 5, 2014 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.