ProjectDocument.getSelectedDataAsync method (Project apps)
Published: February 26, 2013
Asynchronously gets the data that is contained in the current selection of one or more cells in the Gantt chart.
Office.context.document.getSelectedDataAsync(coercionType [, options], callback);
When the function that you pass to the callback parameter executes, it receives an AsyncResult object that you can access from the parameter in the callback function. Use the AsyncResult.value property to access the values in the current selection. The values are returned in the "text" format that is specified by the coercionType parameter.
To determine the success or failure of the operation, use the AsyncResult.status property. If the operation fails, use the AsyncResult.error property to access an Error object that provides information about the error.
The ProjectDocument.getSelectedDataAsync method overrides the Document.getSelectedDataAsync method, to return the text value of data that is selected in one or more cells in the Project Gantt chart. The ProjectDocument.getSelectedDataAsync method supports only "text" for the CoercionType parameter; it does not support "matrix", "table", or other values.
In the following example, the showSelectedText method gets the unformatted text value of all selected cells in the current grid view of the active project, and displays the value or the error information.
In the following code, the textBox object is a reference to a textarea control in an HTML file, for example: <textarea id="textBox" rows="6" cols="25"></textarea>
var _projDoc; // The initialize function is required for all apps. Office.initialize = function (reason) { // Checks for the DOM to load using the jQuery ready function. $(document).ready(function () { // After the DOM is loaded, app-specific code can run. _projDoc = Office.context.document; }); } function showSelectedText() { _projDoc.getSelectedDataAsync( Office.CoercionType.Text, { asyncContext: "any object" }, function (asyncResult) { if (asyncResult.status === Office.AsyncResultStatus.Failed) { var error = asyncResult.error; textBox.value = error.name + ': ' + error.message; } else { var textValue = asyncResult.value; textBox.value = 'Selected data:\n' + textValue + '\nPassthrough data:\n' + asyncResult.asyncContext; } } ); }
|
Supported clients |
Project Standard 2013 and Project Professional 2013 |
|
Libraries |
Office.js, Project-15.js |
|
Namespace |
Office |
Note