### 配置项`toolbarCustom`
> 配置工具栏自定义按钮
#### 参数`arrau $options 选项`
> 选项通过快捷函数`table_toolbar_custom_helper`构建
#### `table_toolbar_custom_helper`传参
~~~
@param string $pos
- left 工具栏内左边
- right 工具栏内右边
@param array $options
- title string 按钮标题
- icon string 按钮图标
- option string 选项
- page 页面
- modal 模态框
- ajax XMLHttpRequest
- route string 路由
- params array 参数
- method string 访问动作, ajax有效 只支持`get`、`post`
- width string 当前type为modal时有效,指定modal的宽,默认800px
- height string 当前type为modal时有效,指定modal的高,默认520px
~~~
示例代码:
~~~
return ViewBuilder::table()
->setTitle('会员列表')
->setPage(true)
->setHideCheckbox(false)
->setToolbarCustom([
table_toolbar_custom_helper('left', [
'title' => '禁用',
'icon' => 'glyphicon glyphicon-remove',
'option' => 'ajax',
'method' => 'POST',
'route' => 'admin/index/disable',
'params' => ['id', 'status'],
]),
table_toolbar_custom_helper('left', [
'title' => '新增',
'icon' => 'glyphicon glyphicon-plus',
'option' => 'modal',
'width' => '60%',
'height' => '80%',
'route' => 'admin/index/edit',
]),
table_toolbar_custom_helper('left', [
'title' => '页面',
'icon' => 'glyphicon glyphicon-list-alt',
'option' => 'page',
'params' => ['id', 'status'],
'route' => 'admin/index/edit',
]),
])
->setColumns([
'password',
'username' => table_column_helper('用户名', ['style' => ['min-width' => '100px']]),
'an_mobile' => table_column_helper('电话', ['style' => ['min-width' => '100px']], function ($item) {
return '+' . $item['an'] . ' ' . $item['mobile'];
}),
'email' => table_column_helper('邮箱', ['style' => ['min-width' => '200px']]),
])
->setQuery(function () {
$query = AdminUser::find()->select(['id', 'username', 'password', 'email', 'an', 'mobile', 'status']);
return $query;
})
->setOrderBy('id DESC')
->setPrimaryKey('id')
->render($this);
~~~
示例图示:
![](https://img.kancloud.cn/3c/9d/3c9d9601a6e9da27e264807e01ca1502_1687x925.png)
![](https://img.kancloud.cn/27/76/27769371b18080867f999c21a0443bc6_1695x936.png)
![](https://img.kancloud.cn/a5/4e/a54e3643c8edd4e9d0a4512993faae04_1699x936.png)
![](https://img.kancloud.cn/17/14/171435102e99535ae24ee54646478eed_1705x984.png)
![](https://img.kancloud.cn/71/f6/71f6645fa271ef947f89124ca1351383_1899x685.png)