Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

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.
0
Isaac
Asked:
Isaac
2 Solutions
 
StealthyDevCommented:
Can you attach the HTML being rendered once the script is executed?
0
 
Melih SARICACommented:
this code looks fine.. what is the problem ?
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Melih SARICACommented:
DO u want to prevent user editing a spesific column  or editing that line(item)?.

IF u want to prevent user editing a spesific line(item), U can create a group for Only viewing and then add users to that group and remove from other groups that ave edit permission.

this ll prevent user to edit line(item)
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
I want to prevent the user from editing a column based on the group they are a part of.
0
 
Melih SARICACommented:
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
0
 
dhawalsethCommented:
Dear Innovator,
You need to be more specific. You told us that you don't want user to edit a column value based on his/her group. You are requesting us to tell you- "how to remove the 'Edit Item' option from ECB(Edit Control Block)?". These are contradicting statements.

To Edit the ECB follow the links mentioned below: (you can use a feature or javascript to achieve the same.)
Note: Let me remind you, if you edit the ECB be specific with the list name or some condition; else you will remove the Edit Item from all the lists.
------------------------------

1. http://sharepoint.stackexchange.com/questions/6489/removing-an-action-from-list-item-menu
2. http://msdn.microsoft.com/en-us/library/ms414790.aspx
3. http://sharepointsolutions.com/sharepoint-help/blog/2010/02/hiding-sharepoint-list-action-menu-items/
----------------------------------

Few more options are there:
1. Replace the "Title(with edit option)" from the list columns via the list settings > list columns option, with only "Title".
2. Use "Audience Targetting" option from webpart properties to restrict the user based on group. You can have multiple webparts on the page where accessibility/ visibility will depend on the users group.

Mark as answer if helped. Enjoy!!!!
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
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!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now