Ewa.EwaControl.getBrowserUdfs()
**適用対象:**apps for SharePoint | Excel Services | SharePoint Server 2013
この記事の内容
戻り値
注釈
例
指定したEwa.EwaControl オブジェクトに関連付けられているEwa.BrowserUdfs オブジェクトを取得します。
Ewa.EwaControl.getBrowserUdfs();
戻り値
[Type]: Ewa.BrowserUdfs オブジェクト
注釈
**[Ewa.EwaControl.getBrowserUdfs]**では、すべてのブラウザー ユーザー定義関数 (Udf **[EwaControl]のインスタンスに関連付けられた) のコレクションを表す[Ewa.BrowserUdfs]**オブジェクトを返します。追加し個々 のブラウザー UDF UDF が存在する場合は、特定のブラウザーかどうかをチェックを削除またはコレクションからすべてのブラウザー Udf を削除するには、 **[Ewa.BrowserUdfs]**を使います。
例
次の例では、ブラウザーの UDF をページに追加する方法を示します。UDF は、アイテムおよび金額の数量を移動、コストを計算し、6% 割引率コストに数量がアイテムの数が 100 以上の場合します。コードの例をExcel Web Access Web パーツでSharePoint Server 2013で作業していることを前提としています。
<script type="text/javascript">
var ewa = 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);
}
function onApplicationReady(result) {
ewa = Ewa.EwaControl.getInstances().getItem(0);
var udfs = ewa.getBrowserUdfs();
// Add the browser UDF, "DISCOUNT" to the page
udfs.add("DISCOUNT", DISCOUNT, "Gives company discounted price.", false, false);
}
// UDF that returns a discount (6%) for orders with
// 100 or more items; otherwise it returns 0.
function DISCOUNT(quantity, price) {
var theDiscount = 0;
var discountCost = 0;
var initialAmount = 0;
if (quantity >= 100) {
initialAmount = quantity * price;
// Apply a 6% discount
theDiscount = initialAmount * 0.06;
discountCost = initialAmount - theDiscount;
}
else {
discountCost = initialAmount;
}
return discountCost;
}
</script>