Link to home
Create AccountLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

Hide a column

I would like to hide a whole list column called "Metric" if the current user is not part of a group called "ACC".  If he is a part of the group, I want to unhide he "Category" column.

The platform is SharePoint 2007.

<script type="text/javascript" language="javascript" src="http://vm1:35714/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" language="javascript" src="http://vm1:35714/js/jquery.SPServices-0.7.2.min.js"></script>

<script type="text/javascript" language="javascript">
  $(document).ready(function() {
var curUser = $().SPServices.SPGetCurrentUser();
alert(curUser);
    alert("jQuery");
   alert($().SPServices.SPGetCurrentSite());
 $().SPServices({
      operation: "GetGroupCollectionFromUser",
      userLoginName: $().SPServices.SPGetCurrentUser(),
      async: false,
      completefunc: function(xData, Status) {
        if($(xData.responseXML).find("Group[Name='ACC']").length == 0) {
          alert("Hide Metric Column!!");

        }
else
{
   alert("Unhide Category column")
}
      }
   }); /*close().SPServices({ */

  });
</script>

Open in new window


Any help would be much appreciated.
Avatar of StealthyDev
StealthyDev

Can you attach the HTML being rendered once the script is executed?
this code looks fine.. what is the problem ?
Avatar of Isaac

ASKER

What I want to do is prevent the current user from editing an item if they are part of a particular group.  The best way to go is to disable the "Edit Item" option but not sure if that is possible.  If it's not possible, I would like to hide the whole column.

User generated image
SOLUTION
Avatar of Melih SARICA
Melih SARICA
Flag of Türkiye image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Isaac

ASKER

I want to prevent the user from editing a column based on the group they are a part of.
ok.. now eveything is clear..

What u need is to disable that colum.. How u can do is with jquery find that colum with title=urcolumnname

then disable=true
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Isaac

ASKER

dhawalseth,

Sorry it's confusing.  

I am trying to either hide a column or hide the edit option based on the group the user is a part of.  

For example, if I had 3 groups Department A, Department B and Department C.

Department A users should be able to edit its own items in a filtered view and if Department A is in Department B and C's view,  it should only be able to read-only.

Hope that makes sense.

I can't use a feature but I'll try the javascript and target audience you mentioned.

Thanks!