php - CRUD 背包 Laravel 。图表更新,当 Ajax 过滤器改变时
问题描述
请避免给我负面评价谢谢
在 Laravel Backpack 管理员中,当我们单击 Date Range filters 时,它正在过滤我们的表格数据,这工作正常,但我希望 Graph 在我们更改 ajax 过滤器时也得到更改。
据我所知, CrudConTroller 中的 ajax 日期范围过滤器代码:
$this->crud->addFilter([
'type' => 'date_range',
'name' => 'created_at',
'label' => 'Date range'
],
false,
function ($value) { // if the filter is active, apply these constraints
$dates = json_decode($value);
$this->crud->addClause('where', 'created_at', '>=', $dates->from);
$this->crud->addClause('where', 'created_at', '<=', $dates->to . ' 23:59:59');
});
并且图形出现在小部件中,刀片模板文件:list.blade.php。
$widgets['before_content'][] = [
'type' => 'div',
'class' => 'row',
'content' => [ // widgets
[
'type' => 'chart',
'wrapperClass' => 'mt-4 col-md-12',
// 'class' => 'col-md-12',
'controller' => \App\Http\Controllers\Admin\Charts\UserChartController::class,
'content' => [
'header' => 'New Users', // optional
'body' => 'This chart should make it obvious', // optional
]
],
],
]
解决方案
有很多解决方案可以使用 php 来生成图表而不是模板。请参阅中的相关部分。文档。
然后使用请求参数来过滤图表的数据。我将尝试发布一个示例。
推荐阅读
- html - 如何在左侧制作带有圆圈的水平边框
- windows - 如何让 Windows gitlab runner 启动管理 shell
- c# - 如何在 Azure Pipeline 上获得测试覆盖率?
- python - 如何通过变量中的索引调用 pd.Dataframe?
- php - Laravel $id 返回 'en' 而不是 id
- kotlin - 是否有范围函数返回先前的值?
- java - onbackpressed 后关闭对话框窗口
- r - sm.ancova 的事后检验(非参数 ancova)
- javascript - 如何使用javascript或jquery根据输入文本触发列表?
- php - Laravel 8:如何设置所有枚举值的默认值