Gantt Chart Scale - Zoom out to Quarter
-
05-10-2020 - |
Question
Is there a way I can make the Gantt chart scale to display in monthly/quarterly by zooming out default?
Solution 2
<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.
OTHER TIPS
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);
}
});
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange