7/14/2009

SharePoint: Prevent the rescheduling of a task by dragging of the Gantt chart bar

 

When a task list is displayed using a Gantt view the user can reschedule a task (often by accident) by dragging the Gantt task bar with the mouse. It’s easy to prevent this with a tiny piece of JavaScript.

 

Steps:

  • Go the the page with the Gantt view
       http://yourserver/sites/yoursite/lists/yourtasklist/gantt.aspx
  • Click Site Actions, Site Settings, Edit Page
  • Click Add a Web Part and add a Content Editor Web Part (CEWP)
  • Move the CEWP below the Gantt chart web part
  • In the CEWP click Edit then Modify Shared Web Part
  • Click the Source Editor button
  • Paste the code from below
  • Exit the edit mode and try to drag one of the Gantt chart bars.

 

<script> document.all("GanttTable").ondragstart = function () {alert("Task dragging disabled!")} </script>

(The text between the script tags is all one line)

 

The result:

image

No comments:

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.