22

Before I start - I'm new to this SharePoint development lark and am slowly familiarising myself with it.

We're using SharePoint online and I have amended the SharePoint out-of-the-box document library to include some extra fields that are required when the user adds a new document.

If the user creates or uploads a new document then they are prompted to enter the required information. However if they use the drag and drop functionality the entry of the necessary fields is bypassed.

During my search I came across this post which asks how to enforce metadata entry (which would be another good option for me). It also mentions disabling the drag and drop functionality by editing dragdrop.js and removing content from various methods.

I've had a look at the site collection I'm working on (to which I have full control) and I can't seem to find dragdrop.js (or the layouts folder for that matter).

  • Is this something that's held at site collection level or is it held at a higher level?
  • I don't have admin rights above my site collection, do I need them?
  • Do I need to use Visual Studio to make the necessary changes? (Currently I'm doing things through the web and having a bit of a play with Napa I don't have Visual Studio installed)
  • When I get there is it obvious what methods need to be removed?
  • How can I tell SharePoint to use the new version of dragdrop.js? Is it just a case of saving a copy of the existing one to a different name and then editing the existing file?

I suppose the best place for me to have asked this question would probably have been on the existing post, but I am unable to post a comment on there, sorry...

10 Answers 10

24

here is a better solution. Enjoy and let me know if you need more help :)

ExecuteOrDelayUntilScriptLoaded(function() {
    g_uploadType = DragDropMode.NOTSUPPORTED;
    SPDragDropManager.DragDropMode = DragDropMode.NOTSUPPORTED;
}, "DragDrop.js");
1
  • I am having lsit view veb oart on the page and i want to disable the drag drop . For that i have added a CEWP with a js having above snippet .but still able to drag drop the file into that . Please help me out .
    – user27178
    Commented Oct 14, 2015 at 11:17
2

For disable Drag and Drop functionality add below code in "Script Editor".

Go to Setting -> Edit Page -> Insert -> Web Part -> Media and Content -> Script Editor and refresh the library.

<script>
    ExecuteOrDelayUntilScriptLoaded(function() {
             g_uploadType = DragDropMode.NOTSUPPORTED;
             SPDragDropManager.DragDropMode = DragDropMode.NOTSUPPORTED;
        }, "DragDrop.js");
</script>

That's definitely works. I had tried.

1

The layouts folder is not Site Collection specific, it is used for all sites in a farm.

You find it in the web frontend servers at this path: C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS

To modify items here you will need to have access to the folder directly, or have permissions enough to add and install a SharePoint Farm solution.

With that said, you should avoid messing with the OOTB files in SharePoint, you are in danger of voiding your warranty!

2
  • Robert, thanks for the reply. This is not a local install of SharePoint, it is a hosted solution - there is no 'C:\' drive. When I say OOTB, it's an instance of the Document Library web part that I'm amending - not the Document Library content type itself.
    – TonyR
    Commented Nov 14, 2013 at 15:17
  • 2
    The layouts folder still exists on the file system, but naturally you can not modify it in a hosted environment since that would impact all tenants Commented Nov 14, 2013 at 15:31
0

From the Library Menu if you select Modify View and change 'Style' to 'Shaded' it will remove the drag and drop. You end up with more of a list view.

2
  • I'm running into the same situation on a client's SharePoint 2010 site. @lbp I tried changing the style and was hopeful that would work but I am still able to drag and drop. Commented Apr 1, 2015 at 17:02
  • Changing to Shaded it also will render the list at server, so no CSR is possible anymore
    – Emaborsa
    Commented Aug 28, 2018 at 9:44
0

I've found that if you use enable the minor-version functionality it will keep documents that are dropped into the library checked-out until all required metadata is entered. This prevents other users from seeing the document

0

You can disable this with css by setting the drag and drop div style to display: none !important. The !important is required to override the inline styles which are set dynamically.

For pages with a single document library use the id or class e.g.

#ms-dnd-dropbox{ display: none !important; }
.ms-dnd-dropbox{ display: none !important; }

For pages with multiple document libraries when you want to target a specific library prepend the id of the web part div and an underscore e.g. WebPartWPQ4_

#WebPartWPQ4_ms-dnd-dropbox{ display: none !important; }
0

Add following Style & Script to your master page:

<style type="text/css">
    /*-- Hide Drag & Drop --*/
    caption.ms-dragDropAttract {
        caption-side: bottom;
        display: none !important;
    }
</style>
<script type="text/javascript">
    /*-- Stop Drag & Drop --*/
    ExecuteOrDelayUntilScriptLoaded(function () {
        g_uploadType = DragDropMode.NOTSUPPORTED;
        SPDragDropManager.DragDropMode = DragDropMode.NOTSUPPORTED;
        SPDragDropManager.DargDropMode.style.display = "none";
    }, "DragDrop.js");
</script>
1
  • SPDragDropManager.DragDropMode is a number, how could we set a style on it?
    – Emaborsa
    Commented Jan 22, 2019 at 10:28
0

I like the fact that I can change 'Style' to 'Shaded' and it will remove the drag and drop functionality. It also removes the quick edit functionality. Most times users upload not newer versions of documents, but newly named documents and then need to delete the old document. Quick edit is the easiest way to accomplish this.

Since I'm linked in navigation, 5 different views for a document library, one for each Category, it's important that every document gets the category field set. My only solution is to create 5 new pages, add the document library and set the view to one of the 5 categories. Doing all this work to be able to add a few lines of JavaScript to disable the drag and drop functionality seems a bit much.

For now, I will train users to use the upload button and not drag and drop. If this becomes problematic, I will complete the work necessary to disable the drag and drop.

-1

This is may be old post but I am posting it if it helps for others.

  1. Disable Drag and drop functionality
  2. Remove "or drag files here" from the +new document or drag files here.

use the below script by adding to each page as script editor or add it to master page.

  <script type="text/javascript" src="http://code.jquery.com/jquery-
      1.11.1.min.js">
    </script>
<script type="text/javascript">
   ExecuteOrDelayUntilScriptLoaded(function() {
   g_uploadType = DragDropMode.NOTSUPPORTED;
   SPDragDropManager.DragDropMode = DragDropMode.NOTSUPPORTED;
   }, "DragDrop.js");

   $(document).ready(function(){
     if($(".ms-list-addnew span:eq(1)").text()=="new document"){
      $(".ms-list-addnew span:eq(1)").closest("td").html(function(index,oldhtml){ return oldhtml.replace('or drag files here',''); }); }});
</script>
1
  • Do not use jQuery if standard functions are available! For edit the AddItemButton use CSR.
    – Emaborsa
    Commented Aug 28, 2018 at 9:47
-2

If it's IE only, you can force the rendering engine to run in say IE8 mode, which will disable drag n' drop entirely. that would require you customizing the page and updating the META tag, I don't believe there is another way from the page to do it.

Theoretically, you are correct. If you load in another JS file with same function names AFTER the original has loaded it should supersede any function calls with your customer functions. I would rename the file however so you can trace it's loading and the function calls to ensure it is working as expected.

1
  • Thanks Jesus - not all our users will use IE, some PC users use Chrome and our Mac users use Safari.
    – TonyR
    Commented Nov 15, 2013 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.