I have stuck with sorting on my addColumn :
I have this query:
$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);
and in 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": "",
"dataType": "json",
"type": "POST",
"data":{ _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'},
]
});
This code is working fine. I need only myteamcnt sort order...that is not working.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire