?
Solved

Hide a column

Posted on 2012-12-24
8
Medium Priority
?
389 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 19

Assisted Solution

by:Melih SARICA
Melih SARICA earned 750 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
 
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 750 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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)

777 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