Solved

Hide a column

Posted on 2012-12-24
8
380 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

758 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

17 Experts available now in Live!

Get 1:1 Help Now