Ewa.EwaControlCollection.getItem(index)

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Remarks
Example
Applies To

Gets the nth Excel Services Web Part registered instance.

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

Parameters

index

The ordinal value of the Ewa.EwaControl to return.

Return Value

EwaControl

Remarks

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

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.

Example

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.

Parameters

index

<script type="text/javascript">

var EWA1 = null;
var EWA2 = null;

// Add event handler for onload event.
if (window.attachEvent) 
{ 
    window.attachEvent("onload", ewaOmPageLoad);    
} 
else 
{ 
    window.addEventListener("DOMContentLoaded", ewaOmPageLoad, false); 
}
// Add event handler for applicationReady event.
function ewaOmPageLoad()
{
    Ewa.EwaControl.add_applicationReady(GetEwa);
}

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

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

Applies To

Ewa.EwaControlCollection Object

See Also

Concepts

Ewa.EwaControlCollection Methods

Ewa Namespace