0

Is there a way I can make the Gantt chart scale to display in monthly/quarterly by zooming out default?

2 Answers 2

1

The complete function below works well (if you have a single gantt on your page). I found that I sometimes got race conditions where the gantt wasn't rendered before I messed with it so this is avoided by doing it in a timeout to allow time for it to render.

$(function(){
    SP.SOD.executeOrDelayUntilScriptLoaded(ScrollGanttToToday,'jsgrid.js');
    function ScrollGanttToToday(){

        setTimeout(function(){                      
            var theGanttGridObject = $("div [id$='_ListViewWebPartJSGrid']")[0].jsgrid;

            theGanttGridObject.SetGanttZoomLevel(theGanttGridObject.GetGanttZoomLevel()+3);
            theGanttGridObject.SetSplitterPosition(600);
            theGanttGridObject.ScrollGanttToDate(new Date());
            theGanttGridObject.DisableEditing();
        }, 2000);
    }
});
1
  • This worked for me when added to a Script Editor WP on a Site Page with a Task List Gantt View added
    – Fairfield
    Mar 15, 2016 at 4:27
0
<script src="URL for jquery-min.js" type="text/javascript">
    <script type="text/javascript">
    $(function(){
      setTimeout(function(){
    $("th[title='Title']").css({"width":"400px"})
        for (var i = 0; i < 3; ++i) WebPartWPQ2_JSGridController.ZoomOutGantt()
      }, 2000)
    });
    </script>

This script helped me to scale and display the gantt chart in quarter.

1
  • is it possible to make the Gantt Chart show only current week data ?! and also have a search option to look for previous weeks etc?
    – Bucki
    Feb 6, 2017 at 15:33

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.