Avatar of Isaac
Isaac
Flag 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.
jQueryMicrosoft SharePoint

Avatar of undefined
Last Comment
Isaac

8/22/2022 - Mon
StealthyDev

Can you attach the HTML being rendered once the script is executed?
Melih SARICA

this code looks fine.. what is the problem ?
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.

HideColumn
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
SOLUTION
Melih SARICA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Isaac

ASKER
I want to prevent the user from editing a column based on the group they are a part of.
Melih SARICA

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
dhawalseth

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
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!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.