Export (0) Print
Expand All

Ewa.EwaControl.getInstances()

apps for Office and SharePoint

Last modified: October 03, 2012

Applies to: apps for SharePoint | Excel Services | SharePoint Server 2013

In this article
Return Value
Remarks
Example
Applies To

Gets the EwaControlCollection object with EwaControl instances that can be used.

var value = Ewa.EwaControl.getInstances();

[EwaControl.getInstances] is a static method of the EwaControl class that returns the EwaControlCollection for the page.

The following code example shows how to use the EwaControl.getInstances static method to get a reference to the collection of Excel Web Access Web Parts on the page and then uses the Ewa.EwaControlCollection.getItem(index) method get a separate reference to each of the two Excel Web Access Web Parts on the page. The code example assumes that you are working with Excel Web Access Web Parts on SharePoint Server 2013.


<script type="text/javascript">

// Initialize variables.
var EWA1 = null;
var EWA2 = null;

// Add event handler for onload event.
if (window.attachEvent) 
{ 
    window.attachEvent("onload", ewaOnPageLoad);    
} 
else 
{ 
    window.addEventListener("DOMContentLoaded", ewaOnPageLoad, false); 
}

// Set page event handlers for onload, proceed to the ewaOnPageLoad function defined below once the page has loaded if (window.attachEvent){
    window.attachEvent("onload", ewaOnPageLoad);
}

// Add an event handler for the applicationReady event.
function ewaOnPageLoad()
{
    Ewa.EwaControl.add_applicationReady(onApplicationReady);
}

// Attach to the individual Excel Web Access (EWA) web parts.
function onApplicationReady()
{
    EWA1 = Ewa.EwaControl.getInstances().getItem(0);
    EWA2 = Ewa.EwaControl.getInstances().getItem(1);

    // ...
} 
</script>

Show:
© 2015 Microsoft