Social Icons

twitter google plus linkedin rss feed

Pages

5.4.12

Hiding Edit in Datasheet in the Actions Menu with javascript code

Coming back after all this time to write such an ugly post? That’s exactly my style…
Well, the title of the post explains very well what was the objective and everybody knows that this is not the best way, but editing the permissions was causing issues somewhere else so we decided to do this.
This is the enemy:
Edit in Datasheet
And in order to hide it we added a Content Editor Web Part and then clicked in the Source Editor Button:
Content Editor Web Part Source Editor
There we added this script:
<script type="text/javascript" >
var allMenuItems = document.getElementsByTagName('ie:menuitem'); 
for(var i = 0; i < allMenuItems.length; i++ )   
{
 try
        {
         if (allMenuItems[i].text.toLowerCase() == "edit in datasheet")
         {
   var parentNodeOfMenuItem = allMenuItems[i].parentNode;  
                 parentNodeOfMenuItem.removeChild(allMenuItems[i]);                                
  }
 }
 catch(err)
 {}

} 
</script>

It could look a bit weird, but SharePoint won’t mind. Then we should click Save.
CEWP Source Editor Window
After that, in the Appearance group of the web part we could change the parameter Chrome Type to “None” (Or Layout –> Hidden) to make the CEWP invisible to the users.
And that’s all.
Edit in Datasheet Hidden
Enjoy!

No comments:

Post a Comment

25.2.12

CrossDomain SecurityException accessing my Azure WCF Service from Silverlight

Just uploaded a WCF Service Web Role to Azure with the intention of accessing it from a Silverlight web part, but I got the dreaded and almost expected:
System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI 'http://localhost:81/MyService.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details. ---> System.Security.SecurityException ---> System.Security.SecurityException: Security error.
Yes, cool, but how do I add my crossdomain.xml or my clientaccesspolicy.xml files to an “Azure Web Role” which I just heard exists?

To my surprise it’s very easy you just have to add the XMLs to the project:

adding crossdomain.xml and clientaccesspolicy.xml to azure web role

Then you’ll be able to debug and, after you “Upgrade” the package in Azure Hosted service, you’ll be able to access it from Silverlight.

By the way, I don’t like "Upgrade" here, I find it misleading. I would have used Update.

No comments:

Post a Comment