Office.BindingDataChangedEventArgs interface
提供有关引发了 DataChanged 事件的绑定的信息。
注解
使用方
示例
// When data in a binding changes, the handler receives a BindingDataChangedEventArgs object
// containing the binding that changed and the event type.
function addDataChangeHandler() {
Office.context.document.bindings.getByIdAsync("myBinding", function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
asyncResult.value.addHandlerAsync(Office.EventType.BindingDataChanged, onDataChanged);
}
});
}
function onDataChanged(eventArgs: Office.BindingDataChangedEventArgs) {
console.log("Event type: " + eventArgs.type);
console.log("Binding ID: " + eventArgs.binding.id);
// Refresh data from the binding
eventArgs.binding.getDataAsync( { coercionType: Office.CoercionType.Text }, function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
console.log("Updated data: " + asyncResult.value);
}
});
}
属性
| binding | 获取一个 Office.Binding 对象,该对象表示引发 DataChanged 事件的绑定。 |
| type | 获取一个 Office.EventType 枚举值,该值标识引发的事件类型。 |