### 配置项`toolbarRefresh`
> 配置工具栏筛选按钮
#### 参数`array $options 选项`
> -`title string 按钮名称,默认:`
> -`icon string 按钮图标,默认: glyphicon glyphicon-filter`
> -`columns array 列定义`
#### `columns`配置项 `键值对`
1. 键:字段名
2. 值:通过`table_toolbar_filter_helper`构建
#### `table_toolbar_filter_helper`传参 `array $options选项`
> -`control`
~~~
- text 文本
- select 下拉选择框
- number 数字
- datetime 日期
- date 日期
- year 年
- month 月
- time 时间
- custom 自定义
~~~
> -`label` string 标签
> -`range` boolean 是否是区间, 用于日期控件
> -`placeholder` string 提示
> -`default` mixed 默认值
> -`style` array|string 样式
> -`attribute` string|array 属性
> -`options` array 选项,用于select控件
> -`widget` CustomControl 用于自定义
示例代码:
~~~
return ViewBuilder::table()
->setTitle('会员列表')
->setPage(true)
->setHideCheckbox(false)
->setRowActions([
table_action_helper('ajax', [
'title' => '解封/封停',
'icon' => 'fa fa-lock',
'route' => 'admin/index/disable',
'params' => ['id', 'status'],
'method' => 'post',
]),
table_action_helper('division', []),
table_action_helper('modal', [
'title' => '编辑',
'icon' => 'fa fa-pencil-square-o',
'route' => 'admin/index/edit',
'width' => '60%',
'height' => '80%',
]),
table_action_helper('page', [
'title' => '新增',
'icon' => 'fa fa-plus',
'route' => 'admin/index/add',
]),
])
->setToolbarRefresh()
->setToolbarFilter([
'title' => '',
'icon' => '',
'columns' => [
'keyword' => table_toolbar_filter_helper([
'control' => ToolbarFilterOptions::CONTROL_TEXT,
'label' => '关键词',
'placeholder' => '请填写关键词',
]),
/*'email' => table_toolbar_filter_helper([
'control' => ToolbarFilterOptions::CONTROL_NUMBER,
'label' => '数字',
'placeholder' => '请填写数字',
]),*/
'created_at' => table_toolbar_filter_helper([
'control' => ToolbarFilterOptions::CONTROL_DATETIME,
'label' => '注册时间',
'range' => 1,
'placeholder' => '请选择注册时间',
]),
'date' => table_toolbar_filter_helper([
'control' => ToolbarFilterOptions::CONTROL_DATE,
'label' => '日期',
'range' => 1,
'placeholder' => '请选择日期',
]),
'year' => table_toolbar_filter_helper([
'control' => ToolbarFilterOptions::CONTROL_YEAR,
'label' => '年份',
'range' => 1,
'placeholder' => '请选择年份',
]),
'month' => table_toolbar_filter_helper([
'control' => ToolbarFilterOptions::CONTROL_MONTH,
'label' => '月份',
'range' => 1,
'placeholder' => '请选择月份',
]),
'time' => table_toolbar_filter_helper([
'control' => ToolbarFilterOptions::CONTROL_TIME,
'label' => '时间',
'range' => 1,
'placeholder' => '请选择时间',
]),
'status' => table_toolbar_filter_helper([
'control' => ToolbarFilterOptions::CONTROL_SELECT,
'label' => '状态',
'placeholder' => '请选择状态',
'default' => '',
'options' => [
'0' => '封停',
'1' => '正常',
],
]),
/*'custom' => table_toolbar_filter_helper([
'control' => 'custom',
'widget' => new SelectConnection(),
]),*/
],
])
->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/55/0f/550f96e755d9ff9dba63390aef4ee1ff_1689x934.png)
![](https://img.kancloud.cn/41/6b/416b9be78b018bf10d0ee0a8ef80ae94_1696x934.png)
![](https://img.kancloud.cn/70/35/70354e1516d470d8c7b743063c178465_1692x929.png)