Office.Group interface

表示功能区选项卡上的一组控件。

要求集: RibbonApi 1.1

注解

使用方

示例

/**
 * Shows or hides a contextual tab.
 */
async function setContextualTabVisibility(visible: boolean) {
    // Define a tab group of controls.
    const group: Office.Group = {
        id: "TableToolsGroup",
        controls: [
            // The controls of the group...
        ],
    };
    
    // Update the ribbon to show or hide a tab with the specified group of controls.
    await Office.ribbon.requestUpdate({
        tabs: [
            {
                id: "contextTab1",
                visible: visible,
                groups: [group],
            },
        ],
    });
}

属性

controls

指定组中的一个或多个控件,如菜单项、按钮等。

id

清单中指定的组的标识符。

visible

指定控件组在自定义选项卡上是显示还是隐藏。

属性详细信息

controls

指定组中的一个或多个控件,如菜单项、按钮等。

controls?: Control[];

属性值

注解

当对象是传递给 Office.Ribbon 方法的 requestUpdateOffice.RibbonUpdaterData 对象的一部分时Group,controls各种 Office.Group 对象的属性指定哪些控件的启用状态已更改; controls 对象父Tab对象的Group属性将被忽略。

id

清单中指定的组的标识符。

id: string;

属性值

string

visible

指定控件组在自定义选项卡上是显示还是隐藏。

visible?: boolean;

属性值

boolean

注解

要求集: RibbonApi 1.3

示例

// Hide the Reporting Group from the User Tools tab on the ribbon.
const group: Office.Group = {
    id: "Contoso.ReportingGroup",
    visible: false
};
const tab: Office.Tab = {
    id: "Contoso.UserToolsTab",
    groups: [group]
};
// Apply the change to the ribbon.
const ribbonUpdater: Office.RibbonUpdaterData = { tabs: [tab] };
await Office.ribbon.requestUpdate(ribbonUpdater);