SharePoint 2010 – Autozoom Gantt Chart Web Part
15 December 2011 // 2 CommentsTo autozoom your Gantt Chart add this script. You can also add the function to a button, so you don’t have to use the zoom in the ribbon.
WebPartWPQ2_JSGridController is the name of your Gantt Chart object. To see your objectname, right click in your browser, see the source and search in de bottom of your page to the JSON object. You can use more standard functions from the ribbon in this way. Check this jSON info!
$(document).ready(function() {
if(location.href.indexOf('NameOfYourPage.aspx') > 0)
{
setTimeout("SetZoom()", 1000);
}
});
function SetZoom()
{
WebPartWPQ2_JSGridController.ZoomOutGantt();
}
Similar posts
-
SharePoint 2010 - How to hide/remove the recycle bin and view all ...
10 April 2012 // 2 CommentsHow to hide/remove the recycle bin and view all site contents in SharePoint 2010?
-
SharePoint 2010 - Change 'Specify your own value' in a survey
3 April 2012 // 5 CommentsTo change 'Specify your own value' in a survey, just put this code in the NewForm.aspx and EditForm....
-
SharePoint 2010 - Add redirect in survey to manual page after fin ...
2 April 2012 // 11 CommentsToday I wrote a code for a customer that wanted to redirect to a different page after the users clic...
-
SharePiont 2010 - How to backup and restore a SharePoint list wit ...
19 March 2012 // 0 CommentsBackup a SharePoint list with PowerShell: Restore a SharePoint list with PowerShell:
Hello,
thank you for your tip !
I have a little question for you :
How can I obtain the Gantt Chart object name programmatically ?
Thanks in advance.
Auto-answer !
Finally I use this :
var _jsGridControl;
ExecuteOrDelayUntilScriptLoaded(function () {
var oldGanttControl = SP.GanttControl;
SP.GanttControl = function () {
oldGanttControl.call(this);
var oldInit = this.Init;
this.Init = function (jsGridControl, jsRawGridData, params) {
oldInit.call(this, jsGridControl, jsRawGridData, params);
DoCustomizations(jsGridControl);
};
};
}, “SPGantt.js”);
function DoCustomizations(grid) {
_jsGridControl = grid;
}
function OnClientValueChanged(sender, args) {
var oldValue = args.get_oldValue();
var newValue = args.get_newValue();
if (oldValue < newValue) { _jsGridControl.SetGanttZoomLevel(_jsGridControl.GetGanttZoomLevel() + 1);
}
else { _jsGridControl.SetGanttZoomLevel(_jsGridControl.GetGanttZoomLevel() – 1);
}
}
Where function OnClientValueChanged is an event of a slider.
Look on tomblog for more information : http://tomblog.insomniacminds.com/2011/07/09/sharepoint-2010-customizing-the-gantt-view-and-the-client-grid
A+