FilterType 列挙体 / FilterType enumeration / "thisRow"
| 配置はこの状態 |
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title></title>
<script src="../../Scripts/jquery-1.9.1.js" type="text/javascript"></script>
<link href="../../Content/Office.css" rel="stylesheet" type="text/css" />
<script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js" type="text/javascript"></script>
<script src="Home.js" type="text/javascript"></script>
</head>
<body>
<div id="content-main">
<div class="padding">
<div id="control-set" style="display:none">
<button id="get-data-current">Get thisRow</button>
<button id="get-data">Get all</button>
</div>
<div id="data-display"/>
</div>
</div>
</body>
</html>
(function () {
"use strict";
var flg = true;
Office.initialize = function (reason) {
$(document).ready(function () {
addBindingFromSelection();
$('#get-data-current').click(getDataCurrent);
$('#get-data').click(toggleButton);
});
};
function addBindingFromSelection() {
Office.context.document.bindings.getByIdAsync(
"myBinding",
function (result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
$('#control-set').show()
} else {
Office.context.document.bindings.addFromPromptAsync(
Office.BindingType.Table,
{ id: 'myBinding' },
function (result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
$('#control-set').show()
}
})
}
});
}
function toggleButton() {
if (flg) {
$('#get-data').text('Get onlyVisible');
var filter = Office.FilterType.All;
} else {
$('#get-data').text('Get all');
var filter = Office.FilterType.OnlyVisible;
};
getData(filter);
flg = !flg;
}
function getData(filter) {
Office.select("bindings#myBinding").getDataAsync(
{ filterType: filter, },
function (result) {
$('#data-display').empty().append(
filter + ' : ' + result.value.rows
)
});
}
function getDataCurrent() {
Office.select("bindings#myBinding").getDataAsync(
{ rows: "thisRow" },
function (result) {
$('#data-display').empty().append(
'thisRow : ' + result.value.rows
)
});
}
})();
| こんな感じでAccess 用コンテンツ アプリは起動 |
| View でフィルタした、そして thisRow |
| all なのでフィルタを無視する |
| onlyVisible なので フィルタ 条件にあう レコードを取得する |
| rows : thisRow のとき、View にあるデータが取得できる |
| View に表示されていない データ も取得することもある |
| 更新済みの情報が取得されることも |
rows : thisRow とした場合、View 表示に使用されている情報を取得する。
0 件のコメント:
コメントを投稿