Laravel-Yajra数据表排序库

问题描述

我一直坚持对addColumn进行排序:

我有这个查询:

 $userlist = DB::table('vv_users')->select('vv_users.user_id','vv_users.first_name','vv_users.mobile_number','vv_users.user_code','vv_users.user_type','vv_users.child_cnt','vv_users.unique_device_id')->where('vv_users.user_status','=','Active')->whereNotNull('vv_users.uuid');
        return Datatables::of($userlist)
        
       ->addColumn('myteamcnt',function ($userlist) {
            $child_cnt = DB::table('vv_users')->where('user_status','Active')->where('parent_id',$userlist->user_id)->count();
            return $child_cnt;
        })
        
       ->addColumn('whatsappid',function ($userlist) {
            return '<a href="https://api.whatsapp.com/send?phone=91'.$userlist->mobile_number.'&text=Hi%2C%20I%20found%20your%20business%20on%20vanigan" target="_blank" style="border-style: none"><img src="https://img.icons8.com/color/24/000000/whatsapp.png" style="" /></a>';
        })
        ->rawColumns(['whatsappid'])
        ->make(true);
        return Datatables::of($users)->make(true);

和在Blade / js中:

 $('#appmyteamusers').DataTable({
    "processing": true,"serverSide": true,dom: 'Blfrtip',"order": [[3,"desc" ]],lengthMenu: [
    [ 10,25,50,-1 ],[ '10 rows','25 rows','50 rows','Show all' ]
],"iDisplayLength": 50,"ajax":{
        "url": "{{ url('admin/report/postappuserreport') }}","dataType": "json","type": "POST","data":{ _token: "{{csrf_token()}}"}
    },"columns": [
        {data: 'user_id',name: 'vv_users.user_id'},{data: 'first_name',name: 'vv_users.first_name'},{data: 'mobile_number',name: 'vv_users.mobile_number'},{data: 'myteamcnt',name: 'myteamcnt',orderable: true,sortable : true },{data: 'unique_device_id',name: 'vv_users.unique_device_id'},{data: 'whatsappid',name: 'whatsappid'},]
});

此代码运行正常。我只需要myteamcnt排序顺序...不起作用。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...