CRUD背包Laravel.更新Ajax过滤器时的图形更新 [英] CRUD Backpack Laravel . Graph update, when Ajax Filter get changed

查看:85
本文介绍了CRUD背包Laravel.更新Ajax过滤器时的图形更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请避免给我负面评论,谢谢

在Laravel Backpack管理员中,当我们单击日期范围"过滤器时,它正在过滤我们的表数据,效果很好,但是我希望Graph在更改Ajax过滤器时也能被更改.

in Laravel Backpack admin, when we click on Date Range filters , it's Filtering our table data, that is working fine, but I want Graph also get changed when we change ajax filters.

据我所知,CrudConTroller中的ajax日期范围过滤器代码:

as per I know, ajax Date Range filter code in CrudConTroller :

 $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.

and graph is coming in widget, blade templating file : 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来生成图形而不是模板.请参阅中的相关部分.文档.

There's many solution you can use php to generate the graph instead of the template. See the related section in the. documentation.

然后使用request参数过滤图形的数据.我会尝试举一个例子.

Then use the request parameter to filter the data for the graph. I ll try to post an example.

这篇关于CRUD背包Laravel.更新Ajax过滤器时的图形更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆