[comment]: # ({6d5ea9cd-6d5ea9cd})
# 更新

[comment]: # ({/6d5ea9cd-6d5ea9cd})

[comment]: # ({e82cca7f-3db870df})
### 描述

`object templatedashboard.update(object/array templateDashboards)`

这个方法可以更新已经存在的模版仪表盘。

::: noteclassic
此方法仅适用于 *管理员*和*超级管理员* 用户类型。可以在用户角色设置中撤销调用该方法的权限。查看 [用户角色](/manual/web_interface/frontend_sections/users/user_roles)获取更多信息。
:::

[comment]: # ({/e82cca7f-3db870df})

[comment]: # ({d6006aad-051bc982})
### 参数

`(object/array)` 要更新的模板仪表板属性。

必须为每个仪表板指定 `dashboardid` 属性，所有其他属性均为可选。只有指定的属性会被更新。

除了[标准模板仪表板属性](object#template-dashboard)之外，该方法还接受以下参数。

|参数|[类型](/manual/api/reference_commentary#data-types)|说明|
|--|--|------|
|pages|array|用于替换现有仪表板页面的[模板仪表板页面](object#template-dashboard-page)。<br><br>仪表板页面通过 `dashboard_pageid` 属性进行更新。对于不包含 `dashboard_pageid` 属性的对象，将创建新的仪表板页面；如果现有仪表板页面未被复用，则将被删除。仪表板页面将按照指定的顺序排序。只有仪表板页面中指定的属性会被更新。`pages` 属性至少需要一个仪表板页面对象。|

[comment]: # ({/d6006aad-051bc982})

[comment]: # ({d8b2cba8-d8b2cba8})
### 返回值
`(object)` 返回一个对象，该对象包含`dashboardids`属性下更新的模板仪表盘的ID。

[comment]: # ({/d8b2cba8-d8b2cba8})

[comment]: # ({b41637d2-b41637d2})
### 示例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({7e85dec3-7b6290ef})
#### 重命名模版仪表盘

将一个模板仪表盘重命名为 "Performance graphs"。

[请求](/manual/api#执行请求):

```json
{
    "jsonrpc": "2.0",
    "method": "templatedashboard.update",
    "params": {
        "dashboardid": "23",
        "name": "Performance graphs"
    },
    "id": 1
}
```

响应:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "dashboardids": [
            "23"
        ]
    },
    "id": 1
}
```

[comment]: # ({/7e85dec3-7b6290ef})

[comment]: # ({12c7c5a0-cf0dcd1e})
#### 更新模版仪表盘页面

重命名第一个仪表盘页面，替换第二个仪表盘页面上的组件，并添加一个新页面作为第三个页面。 删除所有其他仪表盘页面。

[请求](/manual/api#执行请求):

```json
{
    "jsonrpc": "2.0",
    "method": "templatedashboard.update",
    "params": {
        "dashboardid": "2",
        "pages": [
            {
                "dashboard_pageid": 1,
                "name": "Renamed Page"
            },
            {
                "dashboard_pageid": 2,
                "widgets": [
                    {
                        "type": "clock",
                        "x": 0,
                        "y": 0,
                        "width": 12,
                        "height": 3
                    }
                ]
            },
            {
                "display_period": 60
            }
        ]
    },
    "id": 1
}
```

响应:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "dashboardids": [
            "2"
        ]
    },
    "id": 1
}
```

[comment]: # ({/12c7c5a0-cf0dcd1e})

[comment]: # ({7b2285ce-24de180a})
### 另请参阅

-   [模板仪表板小部件](object#template-dashboard-widget)
-   [模板仪表板小部件
    字段](object#template-dashboard-widget-field)

[comment]: # ({/7b2285ce-24de180a})

[comment]: # ({fb185432-fb185432})
### 来源

CTemplateDashboard::update() 在 *ui/include/classes/api/services/CTemplateDashboard.php*.

[comment]: # ({/fb185432-fb185432})
