访问Project Server 2013 Preview的JS Grid [英] Accessing the JS Grid for Project Server 2013 Preview
问题描述
我正在测试Project Server 2013 预览,我想知道如何使用
<从WebPart或客户端的其他东西访问PWA中的JS Grid实例< span style ="color:#2a2a2a; font-family:'Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif; font-size:14px; line-height:18px">
ECMAScript( JavaScript)。我需要附加事件处理程序(例如,用于 OnRowFocusChanged)。
I'm testing Project Server 2013 Preview and am wondering, how can I access JS Grid instances in PWA from a WebPart or something else on client-side using ECMAScript (JavaScript). I need to attach event handlers (e.g. for OnRowFocusChanged).
在&absp; 演练 对于Project Server
2010 。使用 PJ.AddGridSatelliteInitializationNotifier和 PJ.ProjectCenterSatellite
(适用于Project Center JS Grid):
There was an example in a walkthrough For Project Server 2010. With using PJ.AddGridSatelliteInitializationNotifier and PJ.ProjectCenterSatellite (for Project Center JS Grid):
function ProjectCenterExtension() {
var _grid; // Display surface (a view) of the JS Grid.
var _satellite; // Control wrapper for the JS Grid.
// Prevent ECMAScript errors if PJ or the AddGridSatellite function are not defined.
// If the page is from Project Server, the PJ namespace is defined.
// If the Project page includes JS Grid, the AddGridSatelliteInitializationNotifier
// function is defined.
if (window.PJ == null || PJ.AddGridSatelliteInitializationNotifier == null) {
return;
}
// Use the PJ.AddGridSatelliteInitializationNotifier function to get an instance
// of the satellite.
PJ.AddGridSatelliteInitializationNotifier
(
function (satellite) {
if (PJ.ProjectCenterSatellite != null) {
/*** Satellite override: Project code should pass in "satellite" instead of "this". ***/
satellite = PJ._NotifySatelliteInitComplete.arguments[0];
_satellite = satellite;
/***End Satellite override***/
_grid = satellite.GetJsGridControlInstance();
_grid.AttachEvent(SP.JsGrid.EventType.OnRowFocusChanged, RowChanged);
}
}
);
// Other functions. . .
}
但这种方法PS2013预览不再适用。 PJ.ProjectCenterSatellite不存在,以及任何其他以前的JS网格sattelites(在其他PWA页面上)我在PS2010中看到过(例如对于Timesheet等)。
有人可以在文档中给我一个方向或点,在哪里寻找新的 行为 ?
提前致谢!
UDPATE: PJ.AddGridSatelliteInitializationNotifier DOES exist, and sucesfully appends a notifier, BUT it is never called! It seems that JS Grid is never initialized, or it is initialized in a quite different way.
或者项目中心根本不使用JS Grid,而是使用了其他一些组件......那么问题是 - 如何访问和使用它?
推荐答案
/// <reference name="MicrosoftAjax.js"/>
/// <reference path="~/_layouts/inc/pwa/library/shell.js"/>
/// <reference path="~/_layouts/SP.Core.js"/>
/// <reference path="~/_layouts/ps.core.js"/>
/// <reference path="~/_layouts/ps.projectmanagers.js"/>
/// <reference path="~/_layouts/JsGrid.js"/>
/// <reference path="~/_layouts/JsGrid.Gantt.js"/>
var Temp_PCE; // Contains the Project Center extension object.
_spBodyOnLoadFunctionNames.push("Temp_PCE_Main");
function Temp_PCE_Main() {
Temp_PCE = new Temp_GetPCE();
}
function Temp_GetPCE() {
this.GetSelectedProject = function () {
selection = projectCenterComponent.get_GridSatellite().GetJsGridControlInstance().GetSelectedRecordKeys(false);
if (selection.length == 0) {
alert('Please select a project.');
}
else if (selection.length > 1) {
alert('Please select one project.');
}
else {
return selection[0];
}
return null;
}
}
试试这段代码。
Try this code.
这篇关于访问Project Server 2013 Preview的JS Grid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!