1

I want to hide SharePoint list(Three columns) from users. The columns are only see by HR manager and V/Manager. How to Achieve?

I just tried like this:

<script type="text/javascript">
$(document).ready(function() {
 $().SPServices({
  operation: "GetGroupCollectionFromUser",
  userLoginName: $().SPServices.SPGetCurrentUser(),
  async: false,
  completefunc: function(xData, Status) {
  var xml = xData.responseXML.xml;


    if (xml.search('Service Desk Operators') == -1)
     {

       $("select[title=Status;Approves;]").parent().parent().parent().hide(); 

$('nobr:contains("Status","approves")').closest('tr').hide();
   }  
    }
 });
});
</script>
0

I think you want to down the path of finding the correct TD within the ListView.

The ListView webpart is going to render a TABLE element with a summary attribute that will help you target the correct table. That is step 1.

Assuming that you want to target the 4th column, you could write something like this (CSS):

table[summary=YourGridName] tbody tr td:nth-child(4) { display:none; }

If you wanted to write some JavaScript for this, you could try this:

if (hideHRColumns()) { 
    /* your code goes in the 'hideHRColumns' function and returns boolean */
    $("table[summary=YourGridName] tbody tr td:nth-child(4)").empty();
}
0

The attribute selector should have "", for example:

 $('select[title="StatusApproves"]')
0

I have used the same code with a few modifications in it and it is working fine for me.

<script type="text/javascript">
        // site relative url 
        site = "sites/test"
        $(document).ready(function() {
            $().SPServices({
                operation: "GetGroupCollectionFromUser",
                userLoginName: $().SPServices.SPGetCurrentUser({
                    webUrl = site
                }),
                webUrl = site
                async: false,
                completefunc: function(xData, Status) {
                    //If the current User does belong to the group "Service desk Operators"
                    if ($(xData.responseXML).find("Group[Name='Service desk Operators']").length == 1) {
                        alert("User exists");
                        $("select[title=Status;Approves;]").parent().parent().parent().hide();

                        $('nobr:contains("Status","approves")').closest('tr').hide();
                    }
                }
            });
        });
    </script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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