[comment]: # translation:outdated

[comment]: # aside: 5

[comment]: # ({66fb9690-66fb9690})
# dashboard.update

[comment]: # ({/66fb9690-66fb9690})

[comment]: # ({becba6de-f235159f})
### 描述

`object dashboard.update(object/array dashboards)`

此方法用于 update 现有的仪表板。

::: noteclassic
此方法可供任何类型的用户使用。可以在用户角色设置中撤销调用该方法的权限。更多信息请参见 [User
roles](/manual/web_interface/frontend_sections/users/user_roles)。
:::

[comment]: # ({/becba6de-f235159f})

[comment]: # ({eccee0d8-62947aa0})
### 参数

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

每个仪表板必须定义 `dashboardid` 属性，
其他所有属性都是可选的。只有传递的属性会被更新，其余属性将保持不变。

除了[仪表盘](object#仪表盘)之外，
该方法还接受以下参数。

| 参数 | [数据类型](/manual/api/reference_commentary#数据类型) | 描述 |
|--|--|------|
| pages | array | [仪表板页面](object#仪表板页面) 用于替换现有的仪表板页面。<br><br>仪表板页面通过 `dashboard_pageid` 属性进行更新。对于没有 `dashboard_pageid` 属性的 objects，将创建新的仪表板页面，并且如果现有仪表板页面未被重用，则会被删除。仪表板页面的顺序将与指定顺序相同。仅更新仪表板页面中指定的属性。 |
| users | array | [仪表盘用户](object#仪表盘用户) 共享项用于替换现有元素。 |
| userGroups | array | [dashboard-用户组](object#dashboard-用户组) 共享项用于替换现有元素。 |

[comment]: # ({/eccee0d8-62947aa0})

[comment]: # ({28e89b38-28e89b38})
### 返回值

`(object)` 返回一个 object，其中包含在 `dashboardids` 属性下列出的已更新仪表板的 ID。

[comment]: # ({/28e89b38-28e89b38})

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

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

[comment]: # ({d0eb0276-7fcf7de4})
#### 重命名仪表板

将仪表板重命名为“SQL server status”。

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


```json
{
    "jsonrpc": "2.0",
    "method": "dashboard.update",
    "params": {
        "dashboardid": "2",
        "name": "SQL server status"
    },
    "id": 1
}
```
响应：


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

[comment]: # ({/d0eb0276-7fcf7de4})

[comment]: # ({ed5d0499-b8348b8a})
#### 更新仪表板页面

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

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


```json
{
    "jsonrpc": "2.0",
    "method": "dashboard.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]: # ({/ed5d0499-b8348b8a})

[comment]: # ({6990c258-e4a57dd3})
#### 更改仪表盘所有者

仅对管理员和超级管理员可用。

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


```json
{
    "jsonrpc": "2.0",
    "method": "dashboard.update",
    "params": {
        "dashboardid": "2",
        "userid": "1"
    },
    "id": 1
}
```
响应：


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

[comment]: # ({/6990c258-e4a57dd3})

[comment]: # ({299ae089-299ae089})
### 另请参阅

-   [仪表板页面](object#仪表板页面)
-   [仪表板小部件](object#仪表板小部件)
-   [Dashboard widget field](object#dashboard_widget_field)
-   [仪表盘用户](object#仪表盘用户)
-   [dashboard-用户组](object#dashboard-用户组)

[comment]: # ({/299ae089-299ae089})

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

CDashboard::update() 位于
*ui/include/classes/api/services/CDashboard.php* 中。

[comment]: # ({/456ac32b-456ac32b})
