### 配置項`widget`
> 在表格切點處自定義內容
參數1`string|array|yii\base\Widget $widget`
> -`string` Html字符串
> -`array` 批量傳參如:
~~~
[
Table::TABLE_TOOL_TOP => '<p style="padding:10px;padding-bottom:0;">這里是工具欄頭部</p>',
Table::TABLE_TOOL_BOTTOM => '<p style="padding:10px;padding-bottom:0;">這里是工具欄底部</p>',
Table::TABLE_PAGE_TOP => '<p style="padding:10px;padding-bottom:0;">這里是分頁頭部</p>',
Table::TABLE_PAGE_BOTTOM => '<p style="padding:10px;padding-bottom:0;">這里是分頁底部</p>',
]
~~~
> -`yii\base\Widget` 一個實現`Widget`的對象
參數2`int $pos 切點`,當參數1類型為`array`時,該參數無效
~~~
- \app\builder\table\Table::TABLE_TOOL_TOP 工具欄頂部(默認)
- \app\builder\table\Table::TABLE_TOOL_BOTTOM 工具欄底部
- \app\builder\table\Table::TABLE_PAGE_TOP 分頁頂部
- \app\builder\table\Table::TABLE_PAGE_BOTTOM 分頁底部
~~~
示例代碼:
~~~
return ViewBuilder::table()
->setTitle('會員列表')
->setPartial()
->setHideCheckbox(true)
->setWidget([
Table::TABLE_TOOL_TOP => '<p style="padding:10px;padding-bottom:0;">這里是工具欄頭部</p>',
Table::TABLE_TOOL_BOTTOM => '<p style="padding:10px;padding-bottom:0;">這里是工具欄底部</p>',
Table::TABLE_PAGE_TOP => '<p style="padding:10px;padding-bottom:0;">這里是分頁頭部</p>',
Table::TABLE_PAGE_BOTTOM => '<p style="padding:10px;padding-bottom:0;">這里是分頁底部</p>',
])
->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;
})
->render($this);
~~~
示例圖示:
