Hi,
I want to customize the Project center's drilldown page's ribbon. and i could successfully add the button to ribbon. however since PS 2013 has changed it's code to access JSgrid. I am not able to achieve the same.
Here is my code:
/// <reference name="MicrosoftAjax.js"/>
/// <reference path="~/_layouts/inc/pwa/library/Utility.debug.js"/>
/// <reference path="~/_layouts/inc/pwa/library/WebMethodManager.debug.js"/>
/// <reference path="~/_layouts/inc/pwa/library/shell.debug.js"/>
/// <reference path="~/_layouts/inc/pwa/library/projectdrilldownsatellite.js"/>
/// <reference path="~/_layouts/inc/pwa/library/RemoteTextConv.debug.js"/>
/// <reference path="~/_layouts/inc/pwa/library/ProjectFramework.debug.js"/>
/// <reference path="~/_layouts/inc/pwa/library/GridSatellite.debug.js"/>
/// <reference path="~/_layouts/inc/pwa/library/projectserverscripts.debug.js"/>
/// <reference path="~/_layouts/inc/pwa/library/pagepropertymgr.debug.js"/>
/// <reference path="~/_layouts/SP.core.debug.js"/>
/// <reference path="~/_layouts/JsGrid.debug.js"/>
/// <reference path="~/_layouts/JsGrid.Gantt.debug.js"/>
var pc; // Contains the Project Center extension object.
_spBodyOnLoadFunctionNames.push("ApprovalCenterMain");
function ApprovalCenterMain() {
pc = new ApprovalCenterExtension();
}
function ApprovalCenterExtension() {
var _grid; // Display surface (a view) of the JS Grid.
var _satellite; // Control wrapper for the JS Grid.
// Prevent JavaScript errors if PJ or the AddGridSatellite function are not defined.
// If the page is from Project Server, then the PJ namespace is defined.
// If the Project page includes JS Grid, then the AddGridSatellite function is defined.
if (window.PJ == null || PJ.AddGridSatelliteInitializationNotifier == null) {
return;
}
SP.SOD.executeOrDelayUntilScriptLoaded(function () {
JsApi.ExtensibilityManager.AddListener("PJ", function (api, isInited) {
if (isInited == true && api.get_ApiType() == 38) {
API_TSG = api.get_impl();
_grid = api.get_impl()._jsGridControl;
_grid.AttachEvent(SP.JsGrid.EventType.OnRowFocusChanged, OnRowFocusChanged);
_grid.SetDelegate(SP.JsGrid.DelegateType.GetGridRowStyleId, GetGridRowStyleId);
}
});
}, "sp.ribbon.js");
// Use the PJ.AddGridSatelliteInitializationNotifier function to get an instance
// of the satellite.
// StatusApprovalsSatellite
//PJ.AddGridSatelliteInitializationNotifier
//(
// function (satellite) {
// if (PJ.ProjectDrilldownSatelliteImpl != null) {
// alert("Satellite loaded");
// /*** Satellite override: Project code should pass in "sat" instead of "this" ***/
// try {
// satellite = PJ._NotifySatelliteInitComplete.arguments[0];
// //_satellite = satellite;
// /***End Satellite override***/
// _grid = satellite.GetJsGridControlInstance();
// _grid.AttachEvent(SP.JsGrid.EventType.OnRowFocusChanged, RowChanged);
// }
// catch (e)
// { }
// }
// }
//);
function NotifyCallBack(dialogResult, returnValue) {
//SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
SP.UI.Notify.addNotification('Successfully showed selected documents');
}
this.DisplaySelectedRecords = function () {
var selection = _grid.GetSelectedRecordKeys(false);
//alert(selection.length.toString());
var url = "./_layouts/CustomizeApprovalCenter/SelectedItems.aspx?AssnUIDS=";
for (var i = 0; i < selection.length; i++) {
url += selection[i] + "|";
}
//alert(url.toString());
showSPDialog(url);
}
// Show a modal dialog box that contains the selected project URLs.
function showSPDialog(pageToLoad) {
var options = {
url: pageToLoad,
title: 'Selected Documents',
showClose: true,
width: 700,
height: 250,
allowMaximize: false,
showOK: true,
dialogReturnValueCallback: NotifyCallBack
};
SP.UI.ModalDialog.showModalDialog(options);
}
}
I am getting undefine error at "_grid=
api.get_impl()._jsGridControl;"Thanks, Parth