Solved

Hide a column

Posted on 2012-12-24
8
382 Views
Last Modified: 2013-01-07
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
Comment
Question by:Isaac
8 Comments
 
LVL 15

Expert Comment

by:StealthyDev
ID: 38719704
Can you attach the HTML being rendered once the script is executed?
0
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 38719989
this code looks fine.. what is the problem ?
0
 
LVL 5

Author Comment

by:Isaac
ID: 38721243
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
 
LVL 19

Assisted Solution

by:Melih SARICA
Melih SARICA earned 250 total points
ID: 38721447
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 5

Author Comment

by:Isaac
ID: 38721816
I want to prevent the user from editing a column based on the group they are a part of.
0
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 38723072
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
 
LVL 7

Accepted Solution

by:
dhawalseth earned 250 total points
ID: 38723094
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
 
LVL 5

Author Comment

by:Isaac
ID: 38724521
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now