Ewa.EwaControlCollection.getItem(index)

apps for Office and SharePoint

Last modified: October 04, 2012

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

In this article
Return Value
Remarks
Example
Applies To

Gets the nth Excel Services Web Part registered instance.

var value = Ewa.EwaControlCollection.getItem(index);

index

The ordinal value of the Ewa.EwaControl to return.

The index for the [EwaControlCollection] is zero-based. [EwaControlCollection.getItem] returns null if the nth Excel Web Access Web Part instance does not exist.

Important note Important

The Excel Web Access Web Part instances in the Ewa.EwaControlCollection object will not necessarily be in any specific order. To obtain a reference to a specific instance, you can use one of several types of unique information about the Excel Web Access Web Part.

For example, you could use the Workbook path, Session ID, or Edit/View mode associated with the Excel Web Access Web Part to locate a specific instance.

The following code example shows how to use the [EwaControlCollection.getItem] method to get a reference to a specific Excel Web Access Web Part instance on the page. The code example assumes that you are working with an Excel Web Access Web Part on SharePoint Server 2013.

index

<script type="text/javascript">

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); 
}
// Add event handler for applicationReady event.
function ewaOnPageLoad()
{
    Ewa.EwaControl.add_applicationReady(onApplicationReady);
}

// Get a reference to each of the EWAs.
function onApplicationReady()
{
    // Use getItem to get a specific EWA.
    EWA1 = Ewa.EwaControl.getInstances().getItem(0);
    EWA2 = Ewa.EwaControl.getInstances().getItem(1);

    // Add your code here.
} 
</script>

Show:
© 2015 Microsoft