Skip to main content

Elumenotion Blog

Go Search

 
Elumenotion > Elumenotion Blog > Posts > Preventing the Use of Edit in Datasheet
Preventing the Use of Edit in Datasheet

Sometimes you may do some serious customization to a list's forms and build related business logic that precludes the use of the 'Edit in Datasheet' feature that comes with every list. Unfortunately, there isn't an 'Allow Edit in Datasheet' checkbox anywhere on the List Settings page. Fortunately, there are a couple of ways to handle this requirement that are fairly simple.

Option 1 – House of Straw with Javascript

The first way to prevent the use of this menu item is to use javascript to remove the item from the Actions menu. Here is a simple script that uses jQuery (which requires jQuery!) to remove the menu:

$(document).ready(function() { 

   $("[text='Edit in Datasheet']").remove();

});

 

This isn't a bad start, because it will certainly remove the menu option, but it isn't very reliable because a well informed user can simply hand-craft a URL that includes ShowInGrid=True as part of the query string.

Option 2 – House of Sticks with More Javascript and Some Permissions

You can handle the potential naughty query string by extending the javascript as follows:

var loc = window.location.toString();

if(loc.indexOf('ShowInGrid=True') != -1)

{

   loc=loc.replace('ShowInGrid=True', '');

   alert('You are not allowed to edit this list with a datasheet.');

   window.location = loc;

}

$(document).ready(function() { 

   $("[text='Edit in Datasheet']").remove();

});

There is still a potential issue here if any users have the Manage Lists permission (part of the Design permission level) to the list because they can just create a new view whose freshly generated form lacks your javascript. So, you should make sure you restrict this permission as well.

Option 3 – House of Bricks: No Script Required

The previous options will work fine if your users come at the list from the browser, but what if they have Office and can use Access or another client to link to the data? What if one of them is a secret developer with knowledge of certain magic words and arcane API's? You can protect yourself from those people by removing the following permissions from the list:

  • Use Remote Interfaces (To stop the people from linking to the list with Access, etc.)
  • Use Client Integration Features (To remove Edit in Datasheet. Note: also removes Export to Spreadsheet)

You can accomplish this for a single list by creating a new Permission Level that excludes these permissions. Then, simply break permission inheritance at the list and apply the new Permission Level to the groups that have access to the list.

Comments

Hiding Specific Text

Hi Doug:
Thanks for the EUSP article and here!

I'm almost out of steam and this post gives me hope.  I am trying to hide text in a SharePoint form.  For example, I need to hide the word "red".  Is there a JS solution for this?

Thanks-
Charlie Epes
Buffalo, NY
charlie.epes@fnrm.com
Charlie Epes at 10/23/2009 2:21 PM

Charlie

Yes, but the specifics depend on the html. I used an attribute selector in the example here, but jQuery also has a contains selector http://docs.jquery.com/Selectors/contains#text that returns elements that contain the text.

If you have an element the simply contains 'red' you can use either selector and just use the hide() function. If it contains 'red' and some other text, i.e. 'my red-headed step child', you can use the contains selector to get the element and then use a javascript replace along with the jquery html function to get rid of the text.
Doug at 10/24/2009 9:44 AM

Action Items Still Visible

Doug,
I tried creating a new permission level that excludes the use of Client Integration Features and Remote Interfaces and broke inheritance on the list as suggested to apply the new permission level only, yet the 'Edit in Datasheet' option still appears in the Actions menu.  I found this post that suggests it cannot be hidden via permissions alone: http://www.go4sharepoint.com/Forum/removal-edit-datasheet-create-view-9920.aspx.  Am I misunderstanding something? Thanks for the help...
vic at 6/24/2010 11:27 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Your Name *


Attachments
Follow me on twitter!
  Archive
  Archive (Calendar)
  Skinner Created Themes
  New Skinner Download
  New Skinner Tutorial

©  2009 Elumenotion, LLC  |   SharePoint Training, SharePoint Consulting and SharePoint Staffing
8075 Cavendish Place | Suwanee, Georgia 30024 | + 1 (888) 653-5021